on xenial help sign in
Fix closeAllWindows trigger and capture for anonymous function

This makes sure to trigger closeAllWindows if there is no windows and makes sure doOnCloseAllWindows anonymous functions captures required members.

commit5fd3fb82e3801a424b543d36963fbed94e5d7159 authorMarius Gripsgard <marius@ubports.com> dateFri 20 Sep 2019, 22:27 (7 years ago) parent8a0b6f5
2 files changed+30−16
plugins/WindowManager/TopLevelWindowModel.cpp+6 qml/Components/Dialogs.qml+24−16
plugins/WindowManager/TopLevelWindowModel.cpp+6
@@ -736,6 +736,12 @@ void TopLevelWindowModel::closeAllWindows()
736736 for (auto win : m_windowModel) {
737737 win.window->close();
738738 }
739+
740+ // This is done after the for loop in the unlikely event that
741+ // an app starts in between this
742+ if (m_windowModel.isEmpty()) {
743+ Q_EMIT closedAllWindows();
744+ }
739745}
740746
741747void TopLevelWindowModel::rootFocus(bool focus)
qml/Components/Dialogs.qml+24−16
@@ -222,11 +222,13 @@ MouseArea {
222222 focus: true
223223 text: i18n.tr("Yes")
224224 onClicked: {
225+ doOnClosedAllWindows = function(unitySessionService, rebootDialog) {
226+ return function() {
227+ unitySessionService.reboot();
228+ rebootDialog.hide();
229+ }
230+ }(unitySessionService, rebootDialog);
225231 topLevelSurfaceList.closeAllWindows();
226− doOnClosedAllWindows = function() {
227− unitySessionService.reboot();
228− rebootDialog.hide();
229− }
230232 }
231233 color: theme.palette.normal.negative
232234 Component.onCompleted: if (root.hasKeyboard) forceActiveFocus(Qt.TabFocusReason)
@@ -245,11 +247,13 @@ MouseArea {
245247 focus: true
246248 text: i18n.ctr("Button: Power off the system", "Power off")
247249 onClicked: {
250+ doOnClosedAllWindows = function(root, powerDialog) {
251+ return function() {
252+ powerDialog.hide();
253+ root.powerOffClicked();
254+ }
255+ }(root, powerDialog);
248256 topLevelSurfaceList.closeAllWindows();
249− doOnClosedAllWindows = function() {
250− powerDialog.hide();
251− root.powerOffClicked();
252− }
253257 }
254258 color: theme.palette.normal.negative
255259 Component.onCompleted: if (root.hasKeyboard) forceActiveFocus(Qt.TabFocusReason)
@@ -258,11 +262,13 @@ MouseArea {
258262 width: parent.width
259263 text: i18n.ctr("Button: Restart the system", "Restart")
260264 onClicked: {
265+ doOnClosedAllWindows = function(unitySessionService, powerDialog) {
266+ return function() {
267+ unitySessionService.reboot();
268+ powerDialog.hide();
269+ }
270+ }(unitySessionService, powerDialog);
261271 topLevelSurfaceList.closeAllWindows();
262− doOnClosedAllWindows = function() {
263− unitySessionService.reboot();
264− powerDialog.hide();
265− }
266272 }
267273 }
268274 Button {
@@ -302,11 +308,13 @@ MouseArea {
302308 }
303309
304310 onLogoutReady: {
311+ doOnClosedAllWindows = function(unitySessionService) {
312+ return function() {
313+ Qt.quit();
314+ unitySessionService.endSession();
315+ }
316+ }(unitySessionService);
305317 topLevelSurfaceList.closeAllWindows();
306− doOnClosedAllWindows = function() {
307− Qt.quit();
308− unitySessionService.endSession();
309− }
310318 }
311319 }
312320}