@@ -60,10 +60,14 @@ Item {
6060
6161 focus: true
6262
63+ property bool itemDestroyed: false
6364 sourceComponent: Component {
6465 DesktopStage {
6566 color: "darkblue"
6667 anchors.fill: parent
68+ Component.onDestruction: {
69+ desktopStageLoader.itemDestroyed = true;
70+ }
6771 orientations: Orientations {}
6872 }
6973 }
@@ -99,10 +103,16 @@ Item {
99103 property Item desktopStage: desktopStageLoader.status === Loader.Ready ? desktopStageLoader.item : null
100104
101105 function cleanup() {
106+ desktopStageLoader.itemDestroyed = false;
102107 desktopStageLoader.active = false;
103108
104109 tryCompare(desktopStageLoader, "status", Loader.Null);
105110 tryCompare(desktopStageLoader, "item", null);
111+ // Loader.status might be Loader.Null and Loader.item might be null but the Loader
112+ // actually took place. Likely because Loader waits until the next event loop
113+ // iteration to do its work. So to ensure the reload, we will wait until the
114+ // Shell instance gets destroyed.
115+ tryCompare(desktopStageLoader, "itemDestroyed", true);
106116
107117 killAllRunningApps();
108118