diff --git a/src/Utils.cpp b/src/Utils.cpp index 8ad84e85..c23043a8 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -598,7 +598,7 @@ utils::markdownToHtml(const QString &text, bool rainbowify) int charIdx = 0; while (cmark_iter_next(iter) != CMARK_EVENT_DONE) { 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) continue; @@ -608,7 +608,7 @@ utils::markdownToHtml(const QString &text, bool rainbowify) QString buf; int boundaryStart = 0; int boundaryEnd = 0; - // use QTextBoundaryFinder to iterate ofer graphemes + // use QTextBoundaryFinder to iterate over graphemes QTextBoundaryFinder tbf(QTextBoundaryFinder::BoundaryType::Grapheme, nodeText); while ((boundaryEnd = tbf.toNextBoundary()) != -1) { charIdx++; @@ -654,6 +654,7 @@ utils::markdownToHtml(const QString &text, bool rainbowify) // The buffer is no longer needed. free((char *)tmp_buf); + cmark_node_free(node); auto result = linkifyMessage(escapeBlacklistedHtml(QString::fromStdString(html))).trimmed(); diff --git a/src/main.cpp b/src/main.cpp index 9973b03b..779c7800 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,9 +37,11 @@ #include "notifications/Manager.h" #endif -#if defined(GSTREAMER_AVAILABLE) && (defined(Q_OS_MAC) || defined(Q_OS_WINDOWS)) +#ifdef GSTREAMER_AVAILABLE #include #include + +#include "voip/CallDevices.h" #endif #ifdef QML_DEBUGGING @@ -399,5 +401,13 @@ main(int argc, char *argv[]) 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; } diff --git a/src/voip/CallDevices.cpp b/src/voip/CallDevices.cpp index e47b5960..ee9a7f43 100644 --- a/src/voip/CallDevices.cpp +++ b/src/voip/CallDevices.cpp @@ -248,10 +248,11 @@ tokenise(std::string_view str, char delim) } } +static GstDeviceMonitor *monitor = nullptr; + void CallDevices::init() { - static GstDeviceMonitor *monitor = nullptr; if (!monitor) { monitor = gst_device_monitor_new(); 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 CallDevices::haveMic() const { diff --git a/src/voip/CallDevices.h b/src/voip/CallDevices.h index 951f1ab2..d18ccfb3 100644 --- a/src/voip/CallDevices.h +++ b/src/voip/CallDevices.h @@ -46,4 +46,5 @@ private: public: CallDevices(CallDevices const &) = delete; void operator=(CallDevices const &) = delete; + void deinit(); };