From 15bba0dfe29621bb17cd640ee32daea8018af1dc Mon Sep 17 00:00:00 2001 From: gambas Date: Mon, 11 Jan 2021 03:36:28 +0100 Subject: [PATCH] Avoid a possible crash when raising the Link event. [GB.QT4] * BUG: Avoid a possible crash when raising the Link event. [GB.QT5] * BUG: Avoid a possible crash when raising the Link event. --- gb.qt4/src/webview/c_webview.cpp | 8 ++++++-- gb.qt5/src/webview/c_webview.cpp | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gb.qt4/src/webview/c_webview.cpp b/gb.qt4/src/webview/c_webview.cpp index 49c8e486f..6e0e1d17e 100644 --- a/gb.qt4/src/webview/c_webview.cpp +++ b/gb.qt4/src/webview/c_webview.cpp @@ -572,8 +572,12 @@ void CWebView::titleChanged(const QString &title) void CWebView::linkHovered(const QString &link, const QString &title, const QString &textContent) { void *_object = QT.GetObject(((QWebPage*)sender())->view()); - set_link(THIS, link); - GB.Raise(THIS, EVENT_LINK, 0); + + if (THIS) + { + set_link(THIS, link); + GB.Raise(THIS, EVENT_LINK, 0); + } } /*void CWebView::frameCreated(QWebFrame *frame) diff --git a/gb.qt5/src/webview/c_webview.cpp b/gb.qt5/src/webview/c_webview.cpp index a177813a8..12bfda865 100644 --- a/gb.qt5/src/webview/c_webview.cpp +++ b/gb.qt5/src/webview/c_webview.cpp @@ -406,7 +406,7 @@ END_PROPERTY BEGIN_METHOD_VOID(WebView_Clear) - delete WIDGET->page(); + //delete WIDGET->page(); WIDGET->setPage(new MyWebPage(WIDGET)); QObject::connect(WIDGET->page(), SIGNAL(linkHovered(const QString &)), &WebViewSignalManager::manager, SLOT(linkHovered(const QString &))); @@ -962,8 +962,11 @@ void WebViewSignalManager::linkHovered(const QString &link) { void *_object = QT.GetObject(((QWebEnginePage*)sender())->view()); - set_link(THIS, link); - GB.Raise(THIS, EVENT_LINK, 0); + if (THIS) + { + set_link(THIS, link); + GB.Raise(THIS, EVENT_LINK, 0); + } } void WebViewSignalManager::loadStarted()