Fix lock issue with workspace dialog

CURA-4405

- Add try-except around lock release
- Fix closing the dialog with ESC
This commit is contained in:
Lipu Fei 2017-10-09 15:04:27 +02:00
parent f8122320d4
commit 8a25605413
2 changed files with 25 additions and 4 deletions

View file

@ -272,12 +272,26 @@ class WorkspaceDialog(QObject):
def notifyClosed(self): def notifyClosed(self):
self._result = {} # The result should be cleared before hide, because after it is released the main thread lock self._result = {} # The result should be cleared before hide, because after it is released the main thread lock
self._visible = False self._visible = False
self._lock.release() try:
self._lock.release()
except:
pass
def hide(self): def hide(self):
self._visible = False self._visible = False
self._view.hide() self._view.hide()
self._lock.release() try:
self._lock.release()
except:
pass
@pyqtSlot(bool)
def _onVisibilityChanged(self, visible):
if not visible:
try:
self._lock.release()
except:
pass
@pyqtSlot() @pyqtSlot()
def onOkButtonClicked(self): def onOkButtonClicked(self):
@ -290,7 +304,6 @@ class WorkspaceDialog(QObject):
self._view.hide() self._view.hide()
self.hide() self.hide()
## Block thread until the dialog is closed. ## Block thread until the dialog is closed.
def waitForClose(self): def waitForClose(self):
if self._visible: if self._visible:

View file

@ -10,6 +10,7 @@ import UM 1.1 as UM
UM.Dialog UM.Dialog
{ {
id: base
title: catalog.i18nc("@title:window", "Open Project") title: catalog.i18nc("@title:window", "Open Project")
minimumWidth: 500 * screenScaleFactor minimumWidth: 500 * screenScaleFactor
@ -30,6 +31,7 @@ UM.Dialog
materialResolveComboBox.currentIndex = 0 materialResolveComboBox.currentIndex = 0
} }
} }
Item Item
{ {
anchors.fill: parent anchors.fill: parent
@ -377,7 +379,7 @@ UM.Dialog
anchors.right: ok_button.left anchors.right: ok_button.left
anchors.rightMargin: 2 * screenScaleFactor anchors.rightMargin: 2 * screenScaleFactor
} }
Button Button
{ {
id: ok_button id: ok_button
text: catalog.i18nc("@action:button","Open"); text: catalog.i18nc("@action:button","Open");
@ -386,4 +388,10 @@ UM.Dialog
anchors.right: parent.right anchors.right: parent.right
} }
} }
function reject() {
manager.onCancelButtonClicked();
base.visible = false;
base.rejected();
}
} }