Don't connect to signals until the class has been initialized
While profiling plasmashell memory usage with Vishesh we realized that most of the usage came from loading the Background image repeatedly. We traced it back to this change, where we were connecting to wallpaperChanged before initializing it, so it would initialize it again, loading the wallpaper twice. It's not that we were leaking the object, AFAIK, but loading an image using QQuickImage already raises the memory quite a bit. This change alone reduces by 15% the memory usage of my plasmashell (with 2 screens, that makes it a bit worse, because there's 2 DesktopViews then). REVIEW: 119216
This commit is contained in:
parent
92a8007489
commit
f75eb2d984
@ -61,31 +61,10 @@ ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent, cons
|
||||
|
||||
setAcceptedMouseButtons(Qt::AllButtons);
|
||||
|
||||
connect(m_containment.data(), &Plasma::Containment::appletRemoved,
|
||||
connect(m_containment, &Plasma::Containment::appletRemoved,
|
||||
this, &ContainmentInterface::appletRemovedForward);
|
||||
connect(m_containment.data(), &Plasma::Containment::appletAdded,
|
||||
connect(m_containment, &Plasma::Containment::appletAdded,
|
||||
this, &ContainmentInterface::appletAddedForward);
|
||||
connect(m_containment.data(), &Plasma::Containment::activityChanged,
|
||||
this, &ContainmentInterface::activityChanged);
|
||||
connect(m_containment.data(), &Plasma::Containment::activityChanged,
|
||||
[ = ]() {
|
||||
delete m_activityInfo;
|
||||
m_activityInfo = new KActivities::Info(m_containment->activity(), this);
|
||||
connect(m_activityInfo, &KActivities::Info::nameChanged,
|
||||
this, &ContainmentInterface::activityNameChanged);
|
||||
emit activityNameChanged();
|
||||
});
|
||||
connect(m_containment.data(), &Plasma::Containment::wallpaperChanged,
|
||||
this, &ContainmentInterface::loadWallpaper);
|
||||
connect(m_containment.data(), &Plasma::Containment::containmentTypeChanged,
|
||||
this, &ContainmentInterface::containmentTypeChanged);
|
||||
|
||||
if (m_containment->corona()) {
|
||||
connect(m_containment->corona(), &Plasma::Corona::availableScreenRegionChanged,
|
||||
this, &ContainmentInterface::availableScreenRegionChanged);
|
||||
connect(m_containment->corona(), &Plasma::Corona::availableScreenRectChanged,
|
||||
this, &ContainmentInterface::availableScreenRectChanged);
|
||||
}
|
||||
|
||||
if (!m_appletInterfaces.isEmpty()) {
|
||||
emit appletsChanged();
|
||||
@ -96,7 +75,7 @@ ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent, cons
|
||||
if (!m_containment) {
|
||||
return;
|
||||
}
|
||||
disconnect(m_containment.data(), &Plasma::Containment::appletRemoved,
|
||||
disconnect(m_containment, &Plasma::Containment::appletRemoved,
|
||||
this, &ContainmentInterface::appletRemovedForward);
|
||||
});
|
||||
}
|
||||
@ -164,6 +143,28 @@ void ContainmentInterface::init()
|
||||
if (!m_containment->wallpaper().isEmpty()) {
|
||||
loadWallpaper();
|
||||
}
|
||||
|
||||
connect(m_containment, &Plasma::Containment::activityChanged,
|
||||
this, &ContainmentInterface::activityChanged);
|
||||
connect(m_containment, &Plasma::Containment::activityChanged,
|
||||
[ = ]() {
|
||||
delete m_activityInfo;
|
||||
m_activityInfo = new KActivities::Info(m_containment->activity(), this);
|
||||
connect(m_activityInfo, &KActivities::Info::nameChanged,
|
||||
this, &ContainmentInterface::activityNameChanged);
|
||||
emit activityNameChanged();
|
||||
});
|
||||
connect(m_containment, &Plasma::Containment::wallpaperChanged,
|
||||
this, &ContainmentInterface::loadWallpaper);
|
||||
connect(m_containment, &Plasma::Containment::containmentTypeChanged,
|
||||
this, &ContainmentInterface::containmentTypeChanged);
|
||||
|
||||
if (m_containment->corona()) {
|
||||
connect(m_containment->corona(), &Plasma::Corona::availableScreenRegionChanged,
|
||||
this, &ContainmentInterface::availableScreenRegionChanged);
|
||||
connect(m_containment->corona(), &Plasma::Corona::availableScreenRectChanged,
|
||||
this, &ContainmentInterface::availableScreenRectChanged);
|
||||
}
|
||||
}
|
||||
|
||||
QList <QObject *> ContainmentInterface::applets()
|
||||
|
Loading…
Reference in New Issue
Block a user