ASAN: Fix memory leak in DataSource
Trace: Direct leak of 216 byte(s) in 27 object(s) allocated from: #0 0x544cc0 in operator new(unsigned long) (/home/kfunk/devel/install/kf5/bin/plasmashell+0x544cc0) #1 0x7fb2e9cd77d9 in Plasma::DataSource::setEngine(QString const&) /home/kfunk/devel/src/kf5/plasma-framework/src/declarativeimports/core/datasource.cpp:93:28 #2 0x7fb2e9d5c8f1 in Plasma::DataSource::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /home/kfunk/devel/build/kf5/plasma-framework/src/declarativeimports/core/corebindingsplugin_autogen/EWIEGA46WW/moc_datasource.cpp:330:21
This commit is contained in:
parent
d13f9e6f85
commit
fbfc9bdebb
@ -90,7 +90,7 @@ void DataSource::setEngine(const QString &e)
|
||||
return;
|
||||
}
|
||||
|
||||
m_dataEngineConsumer = new Plasma::DataEngineConsumer();
|
||||
m_dataEngineConsumer.reset(new Plasma::DataEngineConsumer());
|
||||
Plasma::DataEngine *engine = dataEngine(m_engine);
|
||||
if (!engine) {
|
||||
qWarning() << "DataEngine" << m_engine << "not found";
|
||||
@ -101,8 +101,7 @@ void DataSource::setEngine(const QString &e)
|
||||
if (m_dataEngine) {
|
||||
m_dataEngine->disconnect(this);
|
||||
// Deleting the consumer triggers the reference counting
|
||||
delete m_dataEngineConsumer;
|
||||
m_dataEngineConsumer = nullptr;
|
||||
m_dataEngineConsumer.reset();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -24,6 +24,7 @@
|
||||
#define DATASOURCE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
#include <QtQml>
|
||||
#include <QQmlPropertyMap>
|
||||
#include <QQmlParserStatus>
|
||||
@ -188,7 +189,7 @@ private:
|
||||
QQmlPropertyMap *m_data = nullptr;
|
||||
QQmlPropertyMap *m_models = nullptr;
|
||||
Plasma::DataEngine *m_dataEngine = nullptr;
|
||||
Plasma::DataEngineConsumer *m_dataEngineConsumer = nullptr;
|
||||
QScopedPointer<Plasma::DataEngineConsumer> m_dataEngineConsumer;
|
||||
QStringList m_sources;
|
||||
QStringList m_connectedSources;
|
||||
QStringList m_oldSources;
|
||||
|
Loading…
Reference in New Issue
Block a user