mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Fix a few minor leaks (or just memory showing up as not freed in tools)
This commit is contained in:
parent
2157ebb614
commit
7f9af9016d
4 changed files with 28 additions and 5 deletions
|
@ -598,7 +598,7 @@ utils::markdownToHtml(const QString &text, bool rainbowify)
|
||||||
int charIdx = 0;
|
int charIdx = 0;
|
||||||
while (cmark_iter_next(iter) != CMARK_EVENT_DONE) {
|
while (cmark_iter_next(iter) != CMARK_EVENT_DONE) {
|
||||||
cmark_node *cur = cmark_iter_get_node(iter);
|
cmark_node *cur = cmark_iter_get_node(iter);
|
||||||
// only text nodes (no code or semilar)
|
// only text nodes (no code or similar)
|
||||||
if (cmark_node_get_type(cur) != CMARK_NODE_TEXT)
|
if (cmark_node_get_type(cur) != CMARK_NODE_TEXT)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -608,7 +608,7 @@ utils::markdownToHtml(const QString &text, bool rainbowify)
|
||||||
QString buf;
|
QString buf;
|
||||||
int boundaryStart = 0;
|
int boundaryStart = 0;
|
||||||
int boundaryEnd = 0;
|
int boundaryEnd = 0;
|
||||||
// use QTextBoundaryFinder to iterate ofer graphemes
|
// use QTextBoundaryFinder to iterate over graphemes
|
||||||
QTextBoundaryFinder tbf(QTextBoundaryFinder::BoundaryType::Grapheme, nodeText);
|
QTextBoundaryFinder tbf(QTextBoundaryFinder::BoundaryType::Grapheme, nodeText);
|
||||||
while ((boundaryEnd = tbf.toNextBoundary()) != -1) {
|
while ((boundaryEnd = tbf.toNextBoundary()) != -1) {
|
||||||
charIdx++;
|
charIdx++;
|
||||||
|
@ -654,6 +654,7 @@ utils::markdownToHtml(const QString &text, bool rainbowify)
|
||||||
|
|
||||||
// The buffer is no longer needed.
|
// The buffer is no longer needed.
|
||||||
free((char *)tmp_buf);
|
free((char *)tmp_buf);
|
||||||
|
cmark_node_free(node);
|
||||||
|
|
||||||
auto result = linkifyMessage(escapeBlacklistedHtml(QString::fromStdString(html))).trimmed();
|
auto result = linkifyMessage(escapeBlacklistedHtml(QString::fromStdString(html))).trimmed();
|
||||||
|
|
||||||
|
|
14
src/main.cpp
14
src/main.cpp
|
@ -37,9 +37,11 @@
|
||||||
#include "notifications/Manager.h"
|
#include "notifications/Manager.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GSTREAMER_AVAILABLE) && (defined(Q_OS_MAC) || defined(Q_OS_WINDOWS))
|
#ifdef GSTREAMER_AVAILABLE
|
||||||
#include <QAbstractEventDispatcher>
|
#include <QAbstractEventDispatcher>
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#include "voip/CallDevices.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef QML_DEBUGGING
|
#ifdef QML_DEBUGGING
|
||||||
|
@ -399,5 +401,13 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
nhlog::ui()->info("starting nheko {}", nheko::version);
|
nhlog::ui()->info("starting nheko {}", nheko::version);
|
||||||
|
|
||||||
return app.exec();
|
auto returnvalue = app.exec();
|
||||||
|
|
||||||
|
#ifdef GSTREAMER_AVAILABLE
|
||||||
|
CallDevices::instance().deinit();
|
||||||
|
|
||||||
|
gst_deinit();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return returnvalue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,10 +248,11 @@ tokenise(std::string_view str, char delim)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstDeviceMonitor *monitor = nullptr;
|
||||||
|
|
||||||
void
|
void
|
||||||
CallDevices::init()
|
CallDevices::init()
|
||||||
{
|
{
|
||||||
static GstDeviceMonitor *monitor = nullptr;
|
|
||||||
if (!monitor) {
|
if (!monitor) {
|
||||||
monitor = gst_device_monitor_new();
|
monitor = gst_device_monitor_new();
|
||||||
GstCaps *caps = gst_caps_new_empty_simple("audio/x-raw");
|
GstCaps *caps = gst_caps_new_empty_simple("audio/x-raw");
|
||||||
|
@ -273,6 +274,16 @@ CallDevices::init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CallDevices::deinit()
|
||||||
|
{
|
||||||
|
if (monitor) {
|
||||||
|
gst_device_monitor_stop(monitor);
|
||||||
|
g_free(monitor);
|
||||||
|
monitor = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CallDevices::haveMic() const
|
CallDevices::haveMic() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,4 +46,5 @@ private:
|
||||||
public:
|
public:
|
||||||
CallDevices(CallDevices const &) = delete;
|
CallDevices(CallDevices const &) = delete;
|
||||||
void operator=(CallDevices const &) = delete;
|
void operator=(CallDevices const &) = delete;
|
||||||
|
void deinit();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue