diff --git a/python/plugins/GdalTools/tools/dialogBase.py b/python/plugins/GdalTools/tools/dialogBase.py index 35cc42530d4..8616e13a0dd 100644 --- a/python/plugins/GdalTools/tools/dialogBase.py +++ b/python/plugins/GdalTools/tools/dialogBase.py @@ -66,6 +66,14 @@ class GdalToolsBaseDialog(QDialog, Ui_Dialog): self.arguments = QStringList() def reject(self): + if self.process.state() != QProcess.NotRunning: + ret = QMessageBox.warning(self, self.tr( "Warning" ), self.tr( "The command is still running. \nDo you want terminate it anyway?" ), QMessageBox.Yes | QMessageBox.No) + if ret == QMessageBox.No: + return + + self.disconnect(self.process, SIGNAL("error(QProcess::ProcessError)"), self.processError) + self.disconnect(self.process, SIGNAL("finished(int, QProcess::ExitStatus)"), self.processFinished) + self.emit( SIGNAL("closeClicked()") ) def accept(self): @@ -129,16 +137,6 @@ class GdalToolsBaseDialog(QDialog, Ui_Dialog): # called on closing the dialog, stop the process if it's running def onClosing(self): - if self.process.state() != QProcess.NotRunning: - ret = QMessageBox.warning(self, self.tr( "Warning" ), self.tr( "The command is still running. \nDo you want terminate it anyway?" ), QMessageBox.Yes | QMessageBox.No) - if ret == QMessageBox.No: - return - - self.disconnect(self.process, SIGNAL("error(QProcess::ProcessError)"), self.processError) - self.disconnect(self.process, SIGNAL("finished(int, QProcess::ExitStatus)"), self.processFinished) - #self.process.kill() - #print "Debug: " + self.command + " terminated by user" - self.stop() QDialog.reject(self) diff --git a/python/plugins/GdalTools/tools/extentSelector.py b/python/plugins/GdalTools/tools/extentSelector.py index d9adb799db2..80682c7fc24 100644 --- a/python/plugins/GdalTools/tools/extentSelector.py +++ b/python/plugins/GdalTools/tools/extentSelector.py @@ -32,16 +32,21 @@ class GdalToolsExtentSelector(QWidget, Ui_ExtentSelector): self.connect(self.tool, SIGNAL("deactivated()"), self.pause) def stop(self): + if not self.isStarted: + return self.isStarted = False self.btnEnable.setVisible(False) self.tool.reset() self.canvas.unsetMapTool(self.tool) - self.canvas.setMapTool(self.previousMapTool) + if self.previousMapTool != self.tool: + self.canvas.setMapTool(self.previousMapTool) #self.coordsChanged() self.emit( SIGNAL( "selectionStopped()" ) ) def start(self): - self.previousMapTool = self.canvas.mapTool() + prevMapTool = self.canvas.mapTool() + if prevMapTool != self.tool: + self.previousMapTool = prevMapTool self.canvas.setMapTool(self.tool) self.isStarted = True self.btnEnable.setVisible(False)