Skip to content

Commit 1733910

Browse files
committed
fix: memory lack for shell
as title. Log: as title pms: Task-365879
1 parent 1ed5e06 commit 1733910

File tree

8 files changed

+29
-8
lines changed

8 files changed

+29
-8
lines changed

frame/containment.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ DApplet *DContainment::createApplet(const DAppletData &data)
5050
QObject::connect(applet, &DApplet::rootObjectChanged, this, [this, applet]() {
5151
if (auto object = applet->rootObject()) {
5252
D_D(DContainment);
53-
d->m_model->append(object);
53+
d->model()->append(object);
5454
QObject::connect(object, &QObject::destroyed, this, [this, object]() {
5555
D_D(DContainment);
56-
d->m_model->remove(object);
56+
d->model()->remove(object);
5757
});
5858
}
5959
});
@@ -70,7 +70,7 @@ void DContainment::removeApplet(DApplet *applet)
7070
d->m_applets.removeOne(applet);
7171
}
7272
if (auto view = applet->rootObject()) {
73-
d->m_model->remove(view);
73+
d->model()->remove(view);
7474
}
7575
applet->deleteLater();
7676
}
@@ -85,14 +85,14 @@ QList<QObject *> DContainment::appletItems()
8585
{
8686
D_D(DContainment);
8787

88-
return d->m_model->rootObjects();
88+
return d->model()->rootObjects();
8989
}
9090

9191
DAppletItemModel *DContainment::appletItemModel() const
9292
{
9393
D_DC(DContainment);
9494

95-
return d->m_model;
95+
return d->model();
9696
}
9797

9898
DApplet *DContainment::applet(const QString &id) const

frame/private/containment_p.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ class DContainmentPrivate : public DAppletPrivate
2020
public:
2121
explicit DContainmentPrivate(DContainment *qq)
2222
: DAppletPrivate(qq)
23-
, m_model(new DAppletItemModel())
2423
{
25-
24+
}
25+
DAppletItemModel *model() const
26+
{
27+
if (!m_model) {
28+
const_cast<DContainmentPrivate *>(this)->m_model = new DAppletItemModel(const_cast<DContainment *>(q_func()));
29+
}
30+
return m_model;
2631
}
2732
QList<DAppletData> groupList(const DAppletData &data) const;
2833
QList<DApplet *> m_applets;

frame/qmlengine.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class DQmlEnginePrivate : public DObjectPrivate
3636
static QQmlEngine *s_engine = nullptr;
3737
if (!s_engine) {
3838
s_engine = new QQmlEngine();
39+
QObject::connect(s_engine, &QQmlEngine::quit, qApp, &QCoreApplication::quit);
3940
auto paths = s_engine->importPathList();
4041
// high priority for builtin plugin.
4142
paths.prepend(DDE_SHELL_QML_INSTALL_DIR);

panels/notification/common/dataaccessor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ namespace notification {
1414
class DataAccessor
1515
{
1616
public:
17+
virtual ~DataAccessor()
18+
{
19+
}
1720
virtual qint64 addEntity(const NotifyEntity &entity) { Q_UNUSED(entity); return 0; }
1821

1922
virtual void updateEntityProcessedType(qint64 id, int processedType) { Q_UNUSED(id); Q_UNUSED(processedType); }

panels/notification/common/dbaccessor.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ DBAccessor::DBAccessor(const QString &key)
118118
}
119119
}
120120

121+
DBAccessor::~DBAccessor()
122+
{
123+
if (m_connection.isOpen()) {
124+
m_connection.close();
125+
}
126+
}
127+
121128
DBAccessor *DBAccessor::instance()
122129
{
123130
static DBAccessor *instance = nullptr;

panels/notification/common/dbaccessor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class DBAccessor : public DataAccessor
1919
{
2020
public:
2121
explicit DBAccessor(const QString &key);
22+
~DBAccessor() override;
2223

2324
static DBAccessor *instance();
2425

panels/notification/common/notifyentity.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ NotifyEntity::NotifyEntity()
4646
}
4747

4848
NotifyEntity::NotifyEntity(qint64 id, const QString &appName)
49-
: d(new NotifyData())
49+
: NotifyEntity()
5050
{
5151
d->id = id;
5252
d->appName = appName;

panels/notification/server/notificationmanager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ NotificationManager::NotificationManager(QObject *parent)
6969

7070
NotificationManager::~NotificationManager()
7171
{
72+
if (m_persistence) {
73+
delete m_persistence;
74+
m_persistence = nullptr;
75+
}
7276
}
7377

7478
bool NotificationManager::registerDbusService()

0 commit comments

Comments
 (0)