DownloadManager: fixed an issue getting the main window

Sun, 13 May 2018 12:55:08 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 13 May 2018 12:55:08 +0200
changeset 6286
2c8a751d6137
parent 6285
045dc4c38701
child 6287
9a193ff6d24a

DownloadManager: fixed an issue getting the main window

WebBrowser/Download/DownloadItem.py file | annotate | diff | comparison | revisions
WebBrowser/Download/DownloadManager.py file | annotate | diff | comparison | revisions
diff -r 045dc4c38701 -r 2c8a751d6137 WebBrowser/Download/DownloadItem.py
--- a/WebBrowser/Download/DownloadItem.py	Sun May 13 12:53:27 2018 +0200
+++ b/WebBrowser/Download/DownloadItem.py	Sun May 13 12:55:08 2018 +0200
@@ -46,7 +46,7 @@
     DownloadSuccessful = 1
     DownloadCancelled = 2
     
-    def __init__(self, downloadItem=None, pageUrl="", parent=None):
+    def __init__(self, downloadItem=None, pageUrl=None, parent=None):
         """
         Constructor
         
@@ -83,7 +83,10 @@
         self.fileIcon.setPixmap(icon.pixmap(48, 48))
         
         self.__downloadItem = downloadItem
-        self.__pageUrl = pageUrl
+        if pageUrl is None:
+            self.__pageUrl = QUrl()
+        else:
+            self.__pageUrl = pageUrl
         self.__bytesReceived = 0
         self.__bytesTotal = -1
         self.__downloadTime = QTime()
diff -r 045dc4c38701 -r 2c8a751d6137 WebBrowser/Download/DownloadManager.py
--- a/WebBrowser/Download/DownloadManager.py	Sun May 13 12:53:27 2018 +0200
+++ b/WebBrowser/Download/DownloadManager.py	Sun May 13 12:55:08 2018 +0200
@@ -260,8 +260,11 @@
                     downloadItem.cancel()
                     return
         
-        pageUrl = \
-            WebBrowserWindow.mainWindow().getWindow().currentBrowser().url()
+        window = WebBrowserWindow.getWindow()
+        if window:
+            pageUrl = window.currentBrowser().url()
+        else:
+            pageUrl = QUrl()
         from .DownloadItem import DownloadItem
         itm = DownloadItem(downloadItem=downloadItem, pageUrl=pageUrl,
                            parent=self)

eric ide

mercurial