inspect element crash on the first time

This commit is contained in:
Xiao YiFang 2022-10-13 20:31:37 +08:00 committed by xiaoyifang
parent e4a083cccc
commit ead9e6132f
3 changed files with 18 additions and 9 deletions

View file

@ -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);

View file

@ -14,6 +14,7 @@ public:
ArticleInspector( QWidget * parent = nullptr );
void setInspectPage( QWebEnginePage * page);
void triggerAction( QWebEnginePage * page );
private:
virtual void closeEvent( QCloseEvent * );

View file

@ -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 )