mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Fix Memory leaks (#1678)
* Refactor to fix #1671
* Add GUI/NonGUI mode to info page
* Do not show lock config, if in non-UI mode
* Updae Changelog
* Correct includes
* Ensure key member initialization - RGB Channels
* Ensure key member initialization - WebServer
* Update RGBChannels
* Fix initialization order
* Fix key when inserting new logger in LoggerMap,
Prepare logBuffer-JSON snapshot view in LoggerManager,
Increase buffered loglines to 500
* Fix Memory leak in GrabberWrapper
* Fix Memory leak in BlackBorderProcessor
* Fix Memory leak in BlackBorderProcessor
* use ninja generator under macos
* Fix BGEffectHandler destruction
* Fix Mdns code
* Clear list after applying qDeleteAll
* Fix deletion of CecHandler
* Fix memory leak caused by wrong buffer allocation
* Remove extra pixel consistently
* Change mDNS to Qt SmartPointers
* Correct removal
* Fix usage of _width/_height (they are the output resolution, not the screen resolution)
That avoids unnecessary resizing of the output image with every transferFrame call
* Move main non Thread Objects to Smart Pointers
* Revert "Move main non Thread Objects to Smart Pointers"
This reverts commit 26102ca963
.
* Add missing deletes
* Revert MdnsBrowser chnage
* Revert MdnsBrowser change
* Fix memory leaks related standalone grabber
* Address CodeQL finding
* delete pointer OsxFrameGrabber
---------
Co-authored-by: Paulchen-Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
@@ -2,9 +2,8 @@
|
||||
#include <qmdnsengine/message.h>
|
||||
#include <qmdnsengine/service.h>
|
||||
|
||||
//Qt includes
|
||||
// Qt includes
|
||||
#include <QThread>
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
@@ -19,7 +18,8 @@
|
||||
|
||||
namespace {
|
||||
const bool verboseBrowser = false;
|
||||
} //End of constants
|
||||
const int SERVICE_LOOKUP_RETRIES = 5;
|
||||
} // End of constants
|
||||
|
||||
MdnsBrowser::MdnsBrowser(QObject* parent)
|
||||
: QObject(parent)
|
||||
@@ -30,7 +30,7 @@ MdnsBrowser::MdnsBrowser(QObject* parent)
|
||||
|
||||
MdnsBrowser::~MdnsBrowser()
|
||||
{
|
||||
qDeleteAll(_browsedServiceTypes);
|
||||
_browsedServiceTypes.clear();
|
||||
}
|
||||
|
||||
void MdnsBrowser::browseForServiceType(const QByteArray& serviceType)
|
||||
@@ -38,11 +38,11 @@ void MdnsBrowser::browseForServiceType(const QByteArray& serviceType)
|
||||
if (!_browsedServiceTypes.contains(serviceType))
|
||||
{
|
||||
DebugIf(verboseBrowser, _log, "Start new mDNS browser for serviceType [%s], Thread: %s", serviceType.constData(), QSTRING_CSTR(QThread::currentThread()->objectName()));
|
||||
QMdnsEngine::Browser* newBrowser = new QMdnsEngine::Browser(&_server, serviceType, &_cache);
|
||||
QSharedPointer<QMdnsEngine::Browser> newBrowser = QSharedPointer<QMdnsEngine::Browser>::create(&_server, serviceType, &_cache);
|
||||
|
||||
QObject::connect(newBrowser, &QMdnsEngine::Browser::serviceAdded, this, &MdnsBrowser::onServiceAdded);
|
||||
QObject::connect(newBrowser, &QMdnsEngine::Browser::serviceUpdated, this, &MdnsBrowser::onServiceUpdated);
|
||||
QObject::connect(newBrowser, &QMdnsEngine::Browser::serviceRemoved, this, &MdnsBrowser::onServiceRemoved);
|
||||
QObject::connect(newBrowser.get(), &QMdnsEngine::Browser::serviceAdded, this, &MdnsBrowser::onServiceAdded);
|
||||
QObject::connect(newBrowser.get(), &QMdnsEngine::Browser::serviceUpdated, this, &MdnsBrowser::onServiceUpdated);
|
||||
QObject::connect(newBrowser.get(), &QMdnsEngine::Browser::serviceRemoved, this, &MdnsBrowser::onServiceRemoved);
|
||||
|
||||
_browsedServiceTypes.insert(serviceType, newBrowser);
|
||||
}
|
||||
@@ -124,8 +124,8 @@ QHostAddress MdnsBrowser::getHostFirstAddress(const QByteArray& hostname)
|
||||
{
|
||||
DebugIf(verboseBrowser, _log, "IP-address for hostname [%s] not yet in cache, start resolver.", toBeResolvedHostName.constData());
|
||||
qRegisterMetaType<QMdnsEngine::Message>("Message");
|
||||
auto* resolver = new QMdnsEngine::Resolver(&_server, toBeResolvedHostName, &_cache);
|
||||
connect(resolver, &QMdnsEngine::Resolver::resolved, this, &MdnsBrowser::onHostNameResolved);
|
||||
_resolver.reset(new QMdnsEngine::Resolver(&_server, toBeResolvedHostName, &_cache));
|
||||
connect(_resolver.get(), &QMdnsEngine::Resolver::resolved, this, &MdnsBrowser::onHostNameResolved);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ void MdnsBrowser::onHostNameResolved(const QHostAddress& address)
|
||||
|
||||
bool MdnsBrowser::resolveAddress(Logger* log, const QString& hostname, QHostAddress& hostAddress, std::chrono::milliseconds timeout)
|
||||
{
|
||||
DebugIf(verboseBrowser, _log, "Get address for hostname [%s], Thread: %s", QSTRING_CSTR(hostname), QSTRING_CSTR(QThread::currentThread()->objectName()));
|
||||
DebugIf(verboseBrowser, log, "Get address for hostname [%s], Thread: %s", QSTRING_CSTR(hostname), QSTRING_CSTR(QThread::currentThread()->objectName()));
|
||||
|
||||
bool isHostAddressOK{ false };
|
||||
if (hostname.endsWith(".local") || hostname.endsWith(".local."))
|
||||
@@ -158,20 +158,20 @@ bool MdnsBrowser::resolveAddress(Logger* log, const QString& hostname, QHostAddr
|
||||
|
||||
if (hostAddress.isNull())
|
||||
{
|
||||
DebugIf(verboseBrowser, _log, "Wait for resolver on hostname [%s]", QSTRING_CSTR(hostname));
|
||||
DebugIf(verboseBrowser, log, "Wait for resolver on hostname [%s]", QSTRING_CSTR(hostname));
|
||||
|
||||
QEventLoop loop;
|
||||
QTimer t;
|
||||
QObject::connect(&MdnsBrowser::getInstance(), &MdnsBrowser::addressResolved, &loop, &QEventLoop::quit);
|
||||
QTimer timer;
|
||||
|
||||
QObject::connect(&MdnsBrowser::getInstance(), &MdnsBrowser::addressResolved, &loop, &QEventLoop::quit);
|
||||
weakConnect(&MdnsBrowser::getInstance(), &MdnsBrowser::addressResolved,
|
||||
[&hostAddress, hostname](const QHostAddress& resolvedAddress) {
|
||||
DebugIf(verboseBrowser, Logger::getInstance("MDNS"), "Resolver resolved hostname [%s] to address [%s], Thread: %s", QSTRING_CSTR(hostname), QSTRING_CSTR(resolvedAddress.toString()), QSTRING_CSTR(QThread::currentThread()->objectName()));
|
||||
[&hostAddress, hostname, log](const QHostAddress& resolvedAddress) {
|
||||
DebugIf(verboseBrowser, log, "Resolver resolved hostname [%s] to address [%s], Thread: %s", QSTRING_CSTR(hostname), QSTRING_CSTR(resolvedAddress.toString()), QSTRING_CSTR(QThread::currentThread()->objectName()));
|
||||
hostAddress = resolvedAddress;
|
||||
});
|
||||
|
||||
QTimer::connect(&t, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||
t.start(static_cast<int>(timeout.count()));
|
||||
QTimer::connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||
timer.start(static_cast<int>(timeout.count()));
|
||||
loop.exec();
|
||||
}
|
||||
|
||||
@@ -206,8 +206,8 @@ QMdnsEngine::Record MdnsBrowser::getServiceInstanceRecord(const QByteArray& serv
|
||||
}
|
||||
|
||||
QMdnsEngine::Record srvRecord;
|
||||
bool found{ false };
|
||||
int retries = 5;
|
||||
bool found { false };
|
||||
int retries { SERVICE_LOOKUP_RETRIES };
|
||||
do
|
||||
{
|
||||
if (_cache.lookupRecord(service, QMdnsEngine::SRV, srvRecord))
|
||||
@@ -393,10 +393,10 @@ QJsonArray MdnsBrowser::getServicesDiscoveredJson(const QByteArray& serviceType,
|
||||
QMap<QByteArray, QByteArray> txtAttributes = txtRecord.attributes();
|
||||
|
||||
QVariantMap txtMap;
|
||||
QMapIterator<QByteArray, QByteArray> i(txtAttributes);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
txtMap.insert(i.key(), i.value());
|
||||
QMapIterator<QByteArray, QByteArray> iterator(txtAttributes);
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next();
|
||||
txtMap.insert(iterator.key(), iterator.value());
|
||||
}
|
||||
obj.insert("txt", QJsonObject::fromVariantMap(txtMap));
|
||||
}
|
||||
|
Reference in New Issue
Block a user