From 696f04aea4065caa5b0b87d1758301b42ced9f5c Mon Sep 17 00:00:00 2001 From: Alex Spataru Date: Sun, 2 Jan 2022 15:51:53 -0500 Subject: [PATCH] Finally fix memory leak --- assets/qml/Windows/MainWindow.qml | 5 ++--- src/JSON/Generator.cpp | 3 --- src/Plugins/Server.cpp | 5 +++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/assets/qml/Windows/MainWindow.qml b/assets/qml/Windows/MainWindow.qml index 9abd5723..3b39e2f2 100644 --- a/assets/qml/Windows/MainWindow.qml +++ b/assets/qml/Windows/MainWindow.qml @@ -158,11 +158,10 @@ FramelessWindow.CustomWindow { target: Cpp_UI_Dashboard function onUpdated() { - if (!root.firstValidFrame) + if (root.firstValidFrame) return - if ((Cpp_IO_Manager.connected || Cpp_CSV_Player.isOpen) && - Cpp_UI_Dashboard.frameValid()) { + if ((Cpp_IO_Manager.connected || Cpp_CSV_Player.isOpen) && Cpp_UI_Dashboard.frameValid()) { setup.hide() root.showDashboard() root.firstValidFrame = true diff --git a/src/JSON/Generator.cpp b/src/JSON/Generator.cpp index 5d139b90..d3860c52 100644 --- a/src/JSON/Generator.cpp +++ b/src/JSON/Generator.cpp @@ -261,9 +261,6 @@ void JSON::Generator::readData(const QByteArray &data) // Create JSON document m_json = QJsonDocument::fromJson(json.toUtf8(), &m_error).object(); - - // Clear strings - json.clear(); } // No parse error, update UI & reset error counter diff --git a/src/Plugins/Server.cpp b/src/Plugins/Server.cpp index 0cbe8814..7dc78ec4 100644 --- a/src/Plugins/Server.cpp +++ b/src/Plugins/Server.cpp @@ -186,7 +186,7 @@ void Plugins::Server::acceptConnection() // React to socket errors // clang-format off #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) - connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), + connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onErrorOccurred(QAbstractSocket::SocketError))); #else connect(socket, &QTcpSocket::errorOccurred, @@ -291,7 +291,8 @@ void Plugins::Server::sendRawData(const QByteArray &data) */ void Plugins::Server::registerFrame(const QJsonObject &json) { - m_frames.append(json); + if (enabled()) + m_frames.append(json); } /**