diff --git a/article_inspect.cpp b/article_inspect.cpp index 9e4547b4..b5851840 100644 --- a/article_inspect.cpp +++ b/article_inspect.cpp @@ -27,19 +27,27 @@ void ArticleInspector::setInspectPage( QWebEnginePage * page ) return; } - qDebug() << page->lifecycleState(); -#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) || QT_VERSION > QT_VERSION_CHECK(6,3,0) ) - page->triggerAction( QWebEnginePage::InspectElement ); -#else - // without this line, application will crash on qt6.2 ,see https://bugreports.qt.io/browse/QTBUG-101724 - // and seems to hangup forever on qt6.3.0 ,so the best solution for now is to comment out the following lines. -#endif - raise(); show(); qDebug() << "inspector finished"; } +void ArticleInspector::triggerAction( QWebEnginePage * page ) +{ + if( !page ) + { + qDebug() << "set inspected page to nullptr"; + return; + } + + setInspectPage(page); + +#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) || QT_VERSION > QT_VERSION_CHECK(6,3,0) ) + page->triggerAction( QWebEnginePage::InspectElement ); +#endif + +} + void ArticleInspector::closeEvent( QCloseEvent * ) { viewContainer->page()->setInspectedPage(nullptr); diff --git a/article_inspect.h b/article_inspect.h index ba4826e0..2a16473b 100644 --- a/article_inspect.h +++ b/article_inspect.h @@ -14,6 +14,7 @@ public: ArticleInspector( QWidget * parent = nullptr ); void setInspectPage( QWebEnginePage * page); + void triggerAction( QWebEnginePage * page ); private: virtual void closeEvent( QCloseEvent * ); diff --git a/mainwindow.cc b/mainwindow.cc index 3a3dfd2c..67613bef 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -1739,7 +1739,7 @@ ArticleView * MainWindow::createNewTab( bool switchToIt, void MainWindow::inspectElement( QWebEnginePage * page ) { - inspector->setInspectPage( page ); + inspector->triggerAction( page ); } void MainWindow::tabCloseRequested( int x )