Fixed an issue causing a crash with latest PyQt5 (5.6).

Mon, 28 Mar 2016 11:51:49 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 28 Mar 2016 11:51:49 +0200
changeset 4891
d6e8171d2c02
parent 4889
10cec9d5aa91
child 4892
64fc1deaeadb

Fixed an issue causing a crash with latest PyQt5 (5.6).

QScintilla/Editor.py file | annotate | diff | comparison | revisions
QScintilla/EditorAssembly.py file | annotate | diff | comparison | revisions
ViewManager/ViewManager.py file | annotate | diff | comparison | revisions
--- a/QScintilla/Editor.py	Sun Mar 27 20:01:17 2016 +0200
+++ b/QScintilla/Editor.py	Mon Mar 28 11:51:49 2016 +0200
@@ -136,7 +136,7 @@
     RequestSyncToken = "REQUEST_SYNC"
     SyncToken = "SYNC"
     
-    def __init__(self, dbs, fn=None, vm=None,
+    def __init__(self, dbs, fn="", vm=None,
                  filetype="", editor=None, tv=None):
         """
         Constructor
@@ -330,7 +330,7 @@
         
         self.isResourcesFile = False
         if editor is None:
-            if self.fileName is not None:
+            if self.fileName:
                 if (QFileInfo(self.fileName).size() // 1024) > \
                    Preferences.getEditor("WarnFilesize"):
                     res = E5MessageBox.yesNo(
@@ -1676,7 +1676,7 @@
         
         @param m modification status
         """
-        if not m and self.fileName is not None:
+        if not m and bool(self.fileName):
             self.lastModified = QFileInfo(self.fileName).lastModified()
         self.modificationStatusChanged.emit(m, self)
         self.undoAvailable.emit(self.isUndoAvailable())
@@ -1850,7 +1850,7 @@
                 self.filetype = "Ruby"
                 return True
             
-            if self.fileName is not None and \
+            if bool(self.fileName) and \
                os.path.splitext(self.fileName)[1] in \
                     self.dbs.getExtensions('Ruby'):
                 self.filetype = "Ruby"
@@ -1868,7 +1868,7 @@
             return True
         
         if self.filetype == "":
-            if self.fileName is not None and \
+            if self.fileName and \
                os.path.splitext(self.fileName)[1] == ".js":
                 self.filetype = "JavaScript"
                 return True
@@ -2968,13 +2968,13 @@
         """
         # save to project, if a project is loaded
         if self.project.isOpen():
-            if self.fileName is not None and \
+            if self.fileName and \
                self.project.startswithProjectPath(self.fileName):
                 path = os.path.dirname(self.fileName)
             else:
                 path = self.project.getProjectPath()
         
-        if not path and self.fileName is not None:
+        if not path and self.fileName:
             path = os.path.dirname(self.fileName)
         if not path:
             path = Preferences.getMultiProject("Workspace") or \
@@ -3054,7 +3054,7 @@
             return False      # do nothing if text wasn't changed
             
         newName = None
-        if saveas or self.fileName is None:
+        if saveas or self.fileName == "":
             saveas = True
             
             fn = self.__getSaveFileName(path)
@@ -5354,7 +5354,7 @@
         
         @return flag indicating this editor should be saved (boolean)
         """
-        return self.fileName is not None and \
+        return bool (self.fileName) and \
             not self.autosaveManuallyDisabled and \
             not self.isReadOnly()
 
@@ -5383,7 +5383,7 @@
         @type str
         """
         if fn != self.fileName and (
-                self.fileName is not None or fn != "(Unnamed)"):
+                bool(self.fileName) or fn != "(Unnamed)"):
             return
         
         self.clearSyntaxError()
@@ -5405,7 +5405,7 @@
         """
         # Check if it's the requested file, otherwise ignore signal
         if fn != self.fileName and (
-                self.fileName is not None or fn != "(Unnamed)"):
+                bool(self.fileName) or fn != "(Unnamed)"):
             return
         
         self.clearSyntaxError()
@@ -6469,7 +6469,7 @@
         @param evt the event, that was generated (QEvent)
         """
         if evt.type() == QEvent.WindowStateChange and \
-           self.fileName is not None:
+           bool(self.fileName):
             if self.windowState() == Qt.WindowStates(Qt.WindowMinimized):
                 cap = os.path.basename(self.fileName)
             else:
@@ -6583,12 +6583,14 @@
         @param bForce True to force change, False to only update and emit
                 signal if there was an attribute change.
         """
-        if self.fileName is None:
+        if self.fileName == "":
             return
+        
         readOnly = not QFileInfo(self.fileName).isWritable() or \
             self.isReadOnly()
         if not bForce and (readOnly == self.isReadOnly()):
             return
+        
         cap = self.fileName
         if readOnly:
             cap = self.tr("{0} (ro)".format(cap))
@@ -7280,7 +7282,7 @@
             and if it is inside a remotely initiated shared edit session
             (boolean, boolean, boolean, boolean)
         """
-        return self.fileName is not None and \
+        return bool(self.fileName) and \
             self.project.isOpen() and \
             self.project.isProjectFile(self.fileName), \
             self.__isShared, self.__inSharedEdit, self.__inRemoteSharedEdit
--- a/QScintilla/EditorAssembly.py	Sun Mar 27 20:01:17 2016 +0200
+++ b/QScintilla/EditorAssembly.py	Mon Mar 28 11:51:49 2016 +0200
@@ -21,7 +21,7 @@
     Class implementing the editor assembly widget containing the navigation
     combos and the editor widget.
     """
-    def __init__(self, dbs, fn=None, vm=None, filetype="", editor=None,
+    def __init__(self, dbs, fn="", vm=None, filetype="", editor=None,
                  tv=None):
         """
         Constructor
--- a/ViewManager/ViewManager.py	Sun Mar 27 20:01:17 2016 +0200
+++ b/ViewManager/ViewManager.py	Mon Mar 28 11:51:49 2016 +0200
@@ -4530,7 +4530,7 @@
         @param filetype type of the source file (string)
         @param fn filename of this view
         @return reference to the new editor object (Editor.Editor) and the new
-            edito assembly object (EditorAssembly.EditorAssembly)
+            editor assembly object (EditorAssembly.EditorAssembly)
         """
         from QScintilla.EditorAssembly import EditorAssembly
         assembly = EditorAssembly(self.dbs, fn, self, filetype=filetype,
@@ -4939,7 +4939,7 @@
         Public slot to generate a new empty editor.
         """
         from QScintilla.EditorAssembly import EditorAssembly
-        assembly = EditorAssembly(self.dbs, None, self,
+        assembly = EditorAssembly(self.dbs, "", self,
                                   tv=e5App().getObject("TaskViewer"))
         editor = assembly.getEditor()
         self.editors.append(editor)

eric ide

mercurial