on xenial help sign in
Properly parent launcher items in all cases

It is required to keep object ownership within C++ or QML would delete items in some circumstances which leads to crashes. Fixes: #1495732 Approved by: Albert Astals Cid

commita397fecafd7d322b123f0e8afc3c8ac09559c8b3 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 10 Mar 2016, 22:43 (11 years ago) parent885b3922fe0e67
3 files changed+4−2
plugins/Unity/Launcher/launcheritem.cpp+1 plugins/Unity/Launcher/launcheritem.h+1−1 plugins/Unity/Launcher/launchermodel.cpp+2−1
plugins/Unity/Launcher/launcheritem.cpp+1
@@ -37,6 +37,7 @@ LauncherItem::LauncherItem(const QString &appId, const QString &name, const QStr
3737 m_alerting(false),
3838 m_quickList(new QuickListModel(this))
3939{
40+ Q_ASSERT(parent != nullptr);
4041 QuickListEntry nameAction;
4142 nameAction.setActionId(QStringLiteral("launch_item"));
4243 nameAction.setText(m_name);
plugins/Unity/Launcher/launcheritem.h+1−1
@@ -32,7 +32,7 @@ class LauncherItem: public LauncherItemInterface
3232{
3333 Q_OBJECT
3434public:
35− LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent = nullptr);
35+ LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent);
3636
3737 QString appId() const override;
3838 QString name() const override;
plugins/Unity/Launcher/launchermodel.cpp+2−1
@@ -389,7 +389,8 @@ void LauncherModel::countVisibleChanged(const QString &appId, bool countVisible)
389389 if (countVisible && desktopFile.isValid()) {
390390 LauncherItem *item = new LauncherItem(appId,
391391 desktopFile.displayName(),
392− desktopFile.icon());
392+ desktopFile.icon(),
393+ this);
393394 item->setCountVisible(true);
394395 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
395396 m_list.append(item);