From 84798c56eaed463f07ce4678e3dfbac7b8f14daf Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Tue, 7 Mar 2023 09:42:23 +0800 Subject: [PATCH] fix:check scanPopup existence --- mainwindow.cc | 10 +++++++--- mainwindow.hh | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mainwindow.cc b/mainwindow.cc index 47a7a117..50375bdf 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -819,7 +819,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ): applyQtStyleSheet( cfg.preferences.addonStyle, cfg.preferences.displayStyle, cfg.preferences.darkMode ); // Scanpopup related - scanPopup = new ScanPopup(nullptr, cfg, articleNetMgr, audioPlayerFactory.player(), + scanPopup = new ScanPopup(this, cfg, articleNetMgr, audioPlayerFactory.player(), dictionaries, groupInstances, history ); scanPopup->setStyleSheet(styleSheet()); @@ -937,6 +937,10 @@ MainWindow::MainWindow( Config::Class & cfg_ ): void MainWindow::clipboardChange( QClipboard::Mode m) { + if( !scanPopup ) + { + return; + } #if defined(HAVE_X11) if(m == QClipboard::Clipboard){ @@ -1154,8 +1158,8 @@ void MainWindow::commitData() cfg.mainWindowGeometry = saveGeometry(); // Save popup window state and geometry - - scanPopup->saveConfigData(); + if( scanPopup ) + scanPopup->saveConfigData(); // Save any changes in last chosen groups etc try diff --git a/mainwindow.hh b/mainwindow.hh index 84672355..f58e060d 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -154,7 +154,7 @@ private: WordFinder wordFinder; - ScanPopup * scanPopup; + ScanPopup * scanPopup = nullptr; sptr< HotkeyWrapper > hotkeyWrapper;