Shut down NetworkManager before deleting WebPage.

Now that the QWebPage actually is a parent of the QNetworkAccessManager, first
setting the page to None and then deleting the QNetworkAccessManager will get
us a RuntimeError because the underlying C++ object is already gone.
This commit is contained in:
Florian Bruhin 2014-09-02 07:01:23 +02:00
parent 7813f8f0c2
commit 892c02268a

View File

@ -278,14 +278,12 @@ class WebView(QWebView):
settings = self.settings()
settings.setAttribute(QWebSettings.JavascriptEnabled, False)
self.stop()
nam = self.page().networkAccessManager()
self.page().networkAccessManager().shutdown()
# Explicitely releasing the page here seems to prevent some segfaults
# when quitting.
# Copied from:
# https://code.google.com/p/webscraping/source/browse/webkit.py#325
self.setPage(None)
nam.shutdown()
del nam
def openurl(self, url):
"""Open a URL in the browser.