From 49060525e94e9c6c6d0b412099d4fc8cb8b217dd Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Fri, 14 Jan 2022 18:55:15 -0600 Subject: stash the webengine view so it can be cleaned up properly later --- browser.py | 25 +++++++++++++------------ 1 file 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) -- cgit v1.2.3