Skip to content

Commit

Permalink
Avoid endless wait cursors in console
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jul 30, 2017
1 parent 973d351 commit 4b6b843
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
22 changes: 10 additions & 12 deletions python/console/console_editor.py
Expand Up @@ -27,6 +27,7 @@
from qgis.PyQt.Qsci import QsciScintilla, QsciLexerPython, QsciAPIs, QsciStyle
from qgis.core import QgsApplication, QgsSettings
from qgis.gui import QgsMessageBar
from qgis.utils import OverrideCursor
import sys
import os
import subprocess
Expand Down Expand Up @@ -726,10 +727,9 @@ def focusInEvent(self, e):
file = open(pathfile, "r")
fileLines = file.readlines()
file.close()
QApplication.setOverrideCursor(Qt.WaitCursor)
for line in reversed(fileLines):
self.insert(line)
QApplication.restoreOverrideCursor()
with OverrideCursor(Qt.WaitCursor):
for line in reversed(fileLines):
self.insert(line)
self.setModified(False)
self.endUndoAction()

Expand Down Expand Up @@ -785,11 +785,10 @@ def loadFile(self, filename, modified):
fn = codecs.open(filename, "rb", encoding='utf-8')
txt = fn.read()
fn.close()
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
self.newEditor.setText(txt)
if self.readOnly:
self.newEditor.setReadOnly(self.readOnly)
QApplication.restoreOverrideCursor()
with OverrideCursor(Qt.WaitCursor):
self.newEditor.setText(txt)
if self.readOnly:
self.newEditor.setReadOnly(self.readOnly)
self.newEditor.setModified(modified)
self.newEditor.recolor()

Expand Down Expand Up @@ -1259,9 +1258,8 @@ def refreshSettingsEditor(self):
if objInspectorEnabled:
cW = self.currentWidget()
if cW and not self.parent.listClassMethod.isVisible():
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
self.listObject(cW)
QApplication.restoreOverrideCursor()
with OverrideCursor(Qt.WaitCursor):
self.listObject(cW)

def changeLastDirPath(self, tab):
tabWidget = self.widget(tab)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gui/GetScriptsAndModels.py
Expand Up @@ -165,7 +165,7 @@ def popupError(self, error=None, url=None):

def grabHTTP(self, url, loadFunction, arguments=None):
"""Grab distant content via QGIS internal classes and QtNetwork."""
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
QApplication.setOverrideCursor(Qt.WaitCursor)
request = QUrl(url)
reply = self.manager.get(QNetworkRequest(request))
if arguments:
Expand Down

0 comments on commit 4b6b843

Please sign in to comment.