diff --git a/frame/containment.cpp b/frame/containment.cpp index b902188bd..05639a67e 100644 --- a/frame/containment.cpp +++ b/frame/containment.cpp @@ -50,10 +50,10 @@ DApplet *DContainment::createApplet(const DAppletData &data) QObject::connect(applet, &DApplet::rootObjectChanged, this, [this, applet]() { if (auto object = applet->rootObject()) { D_D(DContainment); - d->m_model->append(object); + d->model()->append(object); QObject::connect(object, &QObject::destroyed, this, [this, object]() { D_D(DContainment); - d->m_model->remove(object); + d->model()->remove(object); }); } }); @@ -70,7 +70,7 @@ void DContainment::removeApplet(DApplet *applet) d->m_applets.removeOne(applet); } if (auto view = applet->rootObject()) { - d->m_model->remove(view); + d->model()->remove(view); } applet->deleteLater(); } @@ -85,14 +85,14 @@ QList DContainment::appletItems() { D_D(DContainment); - return d->m_model->rootObjects(); + return d->model()->rootObjects(); } DAppletItemModel *DContainment::appletItemModel() const { D_DC(DContainment); - return d->m_model; + return d->model(); } DApplet *DContainment::applet(const QString &id) const diff --git a/frame/private/containment_p.h b/frame/private/containment_p.h index 6c3ce9ec7..ba357844a 100644 --- a/frame/private/containment_p.h +++ b/frame/private/containment_p.h @@ -20,9 +20,14 @@ class DContainmentPrivate : public DAppletPrivate public: explicit DContainmentPrivate(DContainment *qq) : DAppletPrivate(qq) - , m_model(new DAppletItemModel()) { - + } + DAppletItemModel *model() const + { + if (!m_model) { + const_cast(this)->m_model = new DAppletItemModel(const_cast(q_func())); + } + return m_model; } QList groupList(const DAppletData &data) const; QList m_applets; diff --git a/frame/qmlengine.cpp b/frame/qmlengine.cpp index 86eadecd1..8e08d4be2 100644 --- a/frame/qmlengine.cpp +++ b/frame/qmlengine.cpp @@ -36,6 +36,7 @@ class DQmlEnginePrivate : public DObjectPrivate static QQmlEngine *s_engine = nullptr; if (!s_engine) { s_engine = new QQmlEngine(); + QObject::connect(s_engine, &QQmlEngine::quit, qApp, &QCoreApplication::quit); auto paths = s_engine->importPathList(); // high priority for builtin plugin. paths.prepend(DDE_SHELL_QML_INSTALL_DIR); diff --git a/panels/notification/common/dataaccessor.h b/panels/notification/common/dataaccessor.h index d0ae63321..c822427a3 100644 --- a/panels/notification/common/dataaccessor.h +++ b/panels/notification/common/dataaccessor.h @@ -14,6 +14,9 @@ namespace notification { class DataAccessor { public: + virtual ~DataAccessor() + { + } virtual qint64 addEntity(const NotifyEntity &entity) { Q_UNUSED(entity); return 0; } virtual void updateEntityProcessedType(qint64 id, int processedType) { Q_UNUSED(id); Q_UNUSED(processedType); } diff --git a/panels/notification/common/dbaccessor.cpp b/panels/notification/common/dbaccessor.cpp index 7415388b4..25d73b747 100644 --- a/panels/notification/common/dbaccessor.cpp +++ b/panels/notification/common/dbaccessor.cpp @@ -118,6 +118,13 @@ DBAccessor::DBAccessor(const QString &key) } } +DBAccessor::~DBAccessor() +{ + if (m_connection.isOpen()) { + m_connection.close(); + } +} + DBAccessor *DBAccessor::instance() { static DBAccessor *instance = nullptr; diff --git a/panels/notification/common/dbaccessor.h b/panels/notification/common/dbaccessor.h index 3ff59b9ae..da7db81b2 100644 --- a/panels/notification/common/dbaccessor.h +++ b/panels/notification/common/dbaccessor.h @@ -19,6 +19,7 @@ class DBAccessor : public DataAccessor { public: explicit DBAccessor(const QString &key); + ~DBAccessor() override; static DBAccessor *instance(); diff --git a/panels/notification/common/notifyentity.cpp b/panels/notification/common/notifyentity.cpp index f6685df84..956e2e180 100644 --- a/panels/notification/common/notifyentity.cpp +++ b/panels/notification/common/notifyentity.cpp @@ -46,7 +46,7 @@ NotifyEntity::NotifyEntity() } NotifyEntity::NotifyEntity(qint64 id, const QString &appName) - : d(new NotifyData()) + : NotifyEntity() { d->id = id; d->appName = appName; diff --git a/panels/notification/server/notificationmanager.cpp b/panels/notification/server/notificationmanager.cpp index a951482f1..d1c6ee439 100644 --- a/panels/notification/server/notificationmanager.cpp +++ b/panels/notification/server/notificationmanager.cpp @@ -69,6 +69,10 @@ NotificationManager::NotificationManager(QObject *parent) NotificationManager::~NotificationManager() { + if (m_persistence) { + delete m_persistence; + m_persistence = nullptr; + } } bool NotificationManager::registerDbusService()