From d5e8c7eb373eb199759ecd0668d4a9dbead1459c Mon Sep 17 00:00:00 2001 From: Lu Zhen Date: Wed, 21 Feb 2024 14:02:05 +0800 Subject: [PATCH] fix: [extension] cause app cannot exit webview could not quit normally, cause app cannot exit. Log: bug fix Change-Id: Ifd4124da0506d4387835a1dcced2e0d2c9a0761f --- src/plugins/core/gui/plugindetailsview.cpp | 11 ++++++++++- src/plugins/core/gui/plugindetailsview.h | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/plugins/core/gui/plugindetailsview.cpp b/src/plugins/core/gui/plugindetailsview.cpp index 7c584e794..1ac2d079e 100644 --- a/src/plugins/core/gui/plugindetailsview.cpp +++ b/src/plugins/core/gui/plugindetailsview.cpp @@ -22,6 +22,15 @@ DetailsView::DetailsView(QWidget *parent) setupUi(); } +DetailsView::~DetailsView() +{ + if (webView) { + webView->stop(); + // delete webView will cause app cannot exit. + webView->setParent(nullptr); + } +} + void DetailsView::update(const dpf::PluginMetaObjectPointer &metaInfo) { pluginMetaInfo = metaInfo; @@ -94,7 +103,7 @@ void DetailsView::setupUi() logoLabel->setPixmap(QIcon::fromTheme("plugins-navigation").pixmap(QSize(128, 128))); auto webViewLayout = new QHBoxLayout(this); - QWebEngineView *webView = new QWebEngineView(this); + webView = new QWebEngineView(); // TODO(mozart): load from local. // webView->load(QUrl::fromLocalFile("url")); webView->load(QUrl("https://ecology.chinauos.com/adaptidentification/doc_new/#document2?dirid=656d40a9bd766615b0b02e5e")); diff --git a/src/plugins/core/gui/plugindetailsview.h b/src/plugins/core/gui/plugindetailsview.h index 10855bfae..8da72a8d4 100644 --- a/src/plugins/core/gui/plugindetailsview.h +++ b/src/plugins/core/gui/plugindetailsview.h @@ -14,6 +14,7 @@ QT_BEGIN_NAMESPACE class QGridLayout; class QVBoxLayout; class QSpacerItem; +class QWebEngineView; QT_END_NAMESPACE DWIDGET_BEGIN_NAMESPACE @@ -60,6 +61,7 @@ class DetailsView : public DTK_WIDGET_NAMESPACE::DWidget }; explicit DetailsView(QWidget *parent = nullptr); + ~DetailsView(); void update(const dpf::PluginMetaObjectPointer &metaInfo); @@ -73,7 +75,7 @@ private slots: DTK_WIDGET_NAMESPACE::DLabel *metaInfoLabel {nullptr}; DTK_WIDGET_NAMESPACE::DPushButton *loadBtn {nullptr}; dpf::PluginMetaObjectPointer pluginMetaInfo; - + QWebEngineView *webView {nullptr}; }; #endif // PLUGINDETAILSVIEW_H