on xenial help sign in
Make sure we destroy the popups when the item goes away

Another way of doing this would be changing the parent in the createObject calls but if we change that we have to change the x,y logic and since that's quite delicate i decided to go the easy route to not cause regressions

commitd067964fb0ea6205540b4ea8b0c51ef42f3abb56 authorAlbert Astals Cid <albert.astals@canonical.com> dateTue 14 Mar 2017, 11:05 (10 years ago) parent61b737f
2 files changed+17−1
qml/ApplicationMenus/MenuBar.qml+7 qml/ApplicationMenus/MenuPopup.qml+10−1
qml/ApplicationMenus/MenuBar.qml+7
@@ -221,6 +221,13 @@ Item {
221221 }
222222 }
223223 }
224+
225+ Component.onDestruction: {
226+ if (__popup) {
227+ __popup.destroy();
228+ __popup = null;
229+ }
230+ }
224231 } // Item ( delegate )
225232 } // Repeater
226233 } // Row
qml/ApplicationMenus/MenuPopup.qml+10−1
@@ -295,6 +295,8 @@ UbuntuShape {
295295
296296 width: MathUtils.clamp(implicitWidth, d.__minimumWidth, d.__maximumWidth)
297297
298+ property Item popup: null
299+
298300 action.onTriggered: {
299301 submenuHoverTimer.stop();
300302
@@ -346,6 +348,13 @@ UbuntuShape {
346348 }
347349 }
348350 }
351+
352+ Component.onDestruction: {
353+ if (popup) {
354+ popup.destroy();
355+ popup = null;
356+ }
357+ }
349358 }
350359 }
351360
@@ -362,7 +371,7 @@ UbuntuShape {
362371 id: loader
363372 objectName: root.objectName + "-item" + __ownIndex
364373
365− property Item popup: null
374+ readonly property var popup: item ? item.popup : null
366375 property var __menuData: model
367376 property int __ownIndex: index
368377 property bool __isSeparator: model.isSeparator