summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Singleton <matt@xcolour.net>2022-01-14 18:55:15 -0600
committerMatt Singleton <matt@xcolour.net>2022-01-16 13:04:41 -0600
commit49060525e94e9c6c6d0b412099d4fc8cb8b217dd (patch)
tree15d2733ebc5a8b9d190c27c8be038245545cc305
parent09c7b7abbdbf5b12f908d4a88fe5c0098094b2c7 (diff)
stash the webengine view so it can be cleaned up properly later
-rwxr-xr-xbrowser.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/browser.py b/browser.py
index 5eda3b8..54cace9 100755
--- a/browser.py
+++ b/browser.py
@@ -51,6 +51,12 @@ class GBrowser(QtWidgets.QMainWindow):
profile = QtWebEngineCore.QWebEngineProfile.defaultProfile()
QtWidgets.QMainWindow.__init__(self)
+ # Main Viewport
+ self._browser = QtWebEngineWidgets.QWebEngineView()
+ page = GeminiPage(profile, self._browser)
+ self._browser.setPage(page)
+ self.setCentralWidget(self._browser)
+
# Navigation Toolbar
back = QtWidgets.QPushButton("back")
forward = QtWidgets.QPushButton("forward")
@@ -62,24 +68,18 @@ class GBrowser(QtWidgets.QMainWindow):
toolbar.addWidget(address)
self.addToolBar(toolbar)
- # Main Viewport
- browser = QtWebEngineWidgets.QWebEngineView()
- page = GeminiPage(profile, browser)
- browser.setPage(page)
- self.setCentralWidget(browser)
-
# Status Bar
request_status = QtWidgets.QLabel()
self.statusBar().addWidget(request_status)
# Connect signals
- back.clicked.connect(browser.back)
- forward.clicked.connect(browser.forward)
- browser.urlChanged.connect(address.setUrl)
- address.returnPressed.connect(browser.load)
- browser.page().linkHovered.connect(self.set_status_url)
+ back.clicked.connect(self._browser.back)
+ forward.clicked.connect(self._browser.forward)
+ self._browser.urlChanged.connect(address.setUrl)
+ address.returnPressed.connect(self._browser.load)
+ self._browser.page().linkHovered.connect(self.set_status_url)
- browser.load(QtCore.QUrl(initial_url))
+ self._browser.load(QtCore.QUrl(initial_url))
settings = QtCore.QSettings("xcolour.net", "GeminiBrowser")
self.restoreGeometry(settings.value("geometry"))
@@ -97,6 +97,7 @@ class GBrowser(QtWidgets.QMainWindow):
settings = QtCore.QSettings("xcolour.net", "GeminiBrowser")
settings.setValue("geometry", self.saveGeometry())
settings.setValue("windowState", self.saveState())
+ self._browser.page().deleteLater()
super().closeEvent(event)