diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index 5db4f312..d1390535 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -402,11 +402,6 @@ int main(int argc, char **argv) } QTimer::singleShot(0, mainWindow, SLOT(initDbOpen())); - // Connect exit handlers etc.. Beware, apparently this must come - // after mainWindow->show()? - app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); - app.connect(&app, SIGNAL(aboutToQuit()), mainWindow, SLOT(close())); - mainWindow->sSearch->searchTypCMB->setCurrentIndex(prefs.ssearchTyp); mainWindow->sSearch->searchTypeChanged(prefs.ssearchTyp); if (op_flags & OPT_q) { diff --git a/src/qtgui/rclm_idx.cpp b/src/qtgui/rclm_idx.cpp index 2ee55a59..f54b6a40 100644 --- a/src/qtgui/rclm_idx.cpp +++ b/src/qtgui/rclm_idx.cpp @@ -203,23 +203,15 @@ void RclMain::periodic100() } // Possibly cleanup the dead viewers - for (vector::iterator it = m_viewers.begin(); - it != m_viewers.end(); it++) { + for (auto it = m_viewers.begin(); it != m_viewers.end(); ) { int status; if ((*it)->maybereap(&status)) { - deleteZ(*it); + delete *it; + it = m_viewers.erase(it); + } else { + it++; } } - vector v; - for (vector::iterator it = m_viewers.begin(); - it != m_viewers.end(); it++) { - if (*it) - v.push_back(*it); - } - m_viewers = v; - - if (recollNeedsExit) - fileExit(); } // On win32 we have trouble passing filename args on the command line diff --git a/src/qtgui/rclm_wins.cpp b/src/qtgui/rclm_wins.cpp index dbd0f4f9..1b3da16f 100644 --- a/src/qtgui/rclm_wins.cpp +++ b/src/qtgui/rclm_wins.cpp @@ -420,7 +420,7 @@ void RclMain::showActiveTypes() dialog.groupBox->setTitle(tr("Content has been indexed for these MIME types:")); // We replace the list with an editor so that the user can copy/paste - delete dialog.listWidget; + deleteZ(dialog.listWidget); QTextEdit *editor = new QTextEdit(dialog.groupBox); editor->setReadOnly(true); dialog.horizontalLayout->addWidget(editor); @@ -447,7 +447,7 @@ void RclMain::newDupsW(const Rcl::Doc, const vector dups) dialog.groupBox->setTitle(tr("These Urls ( | ipath) share the same" " content:")); // We replace the list with an editor so that the user can copy/paste - delete dialog.listWidget; + deleteZ(dialog.listWidget); QTextEdit *editor = new QTextEdit(dialog.groupBox); editor->setReadOnly(true); dialog.horizontalLayout->addWidget(editor); diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index 80502a18..3c1356b5 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -134,6 +134,10 @@ void RclMain::init() DocSequence::set_translations((const char *)tr("sorted").toUtf8(), (const char *)tr("filtered").toUtf8()); + // A shortcut to get the focus back to the search entry, in table + // mode only. + m_tablefocseq = new QShortcut(QKeySequence("Ctrl+r"), this); + periodictimer = new QTimer(this); // idxstatus file. Make sure it exists before trying to watch it @@ -279,7 +283,6 @@ void RclMain::init() actionShowResultsAsTable->setChecked(prefs.showResultsAsTable); on_actionShowResultsAsTable_toggled(prefs.showResultsAsTable); - // A shortcut to get the focus back to the search entry. QKeySequence seq("Ctrl+Shift+s"); QShortcut *sc = new QShortcut(seq, this); connect(sc, SIGNAL (activated()), sSearch, SLOT (takeFocus())); @@ -462,8 +465,7 @@ void RclMain::enableTrayIcon(bool on) } m_trayicon->show(); } else { - delete m_trayicon; - m_trayicon = 0; + deleteZ(m_trayicon); } } @@ -643,12 +645,12 @@ void RclMain::closeEvent(QCloseEvent *ev) } else { prefs.showmode = PrefsPack::SHOW_NORMAL; } + ev->ignore(); if (prefs.closeToTray && m_trayicon && m_trayicon->isVisible()) { hide(); - ev->ignore(); - } else { - fileExit(); + return; } + fileExit(); } void RclMain::fileExit() @@ -684,18 +686,8 @@ void RclMain::fileExit() rwSettings(true); - // We should do the right thing and let exit() call all the - // cleanup handlers. But we have few persistent resources and qt - // exit is a great source of crashes and pita. So do our own - // cleanup: deleteAllTempFiles(); - // and scram out - LOGDEB("RclMain: fileExit: calling _Exit(0)\n"); -#ifdef USING_WEBENGINE qApp->exit(0); -#else - _Exit(0); -#endif } // Start a db query and set the reslist docsource @@ -886,13 +878,12 @@ void RclMain::on_actionShowResultsAsTable_toggled(bool on) restable->setVisible(on); reslist->setVisible(!on); actionSaveResultsAsCSV->setEnabled(on); - static QShortcut tablefocseq(QKeySequence("Ctrl+r"), this); if (!on) { int docnum = restable->getDetailDocNumOrTopRow(); if (docnum >= 0) { reslist->resultPageFor(docnum); } - disconnect(&tablefocseq, SIGNAL(activated()), + disconnect(m_tablefocseq, SIGNAL(activated()), restable, SLOT(takeFocus())); sSearch->takeFocus(); } else { @@ -903,7 +894,7 @@ void RclMain::on_actionShowResultsAsTable_toggled(bool on) nextPageAction->setEnabled(false); prevPageAction->setEnabled(false); firstPageAction->setEnabled(false); - connect(&tablefocseq, SIGNAL(activated()), + connect(m_tablefocseq, SIGNAL(activated()), restable, SLOT(takeFocus())); } } diff --git a/src/qtgui/rclmain_w.h b/src/qtgui/rclmain_w.h index 2c672388..61867250 100644 --- a/src/qtgui/rclmain_w.h +++ b/src/qtgui/rclmain_w.h @@ -48,6 +48,7 @@ class SpecIdxW; class WebcacheEdit; class ConfIndexW; class RclTrayIcon; +class QShortcut; #include "ui_rclmain.h" @@ -203,6 +204,7 @@ private: QComboBox *m_filtCMB{0}; QButtonGroup *m_filtBGRP{0}; QMenu *m_filtMN{0}; + QShortcut *m_tablefocseq{0}; QFileSystemWatcher m_watcher; vector m_viewers; ExecCmd *m_idxproc{0}; // Indexing process diff --git a/src/qtgui/recoll.pro.in b/src/qtgui/recoll.pro.in index 780c4dac..cfc27eb1 100644 --- a/src/qtgui/recoll.pro.in +++ b/src/qtgui/recoll.pro.in @@ -120,7 +120,10 @@ unix { MOC_DIR = .moc OBJECTS_DIR = .obj LIBS += -L../.libs -lrecoll - + # You will need LD_PRELOAD=/path/to/libasan.xx because -lasan need to be + # first in libs, so can't use LIBS += + # QMAKE_CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer + !macx { # Note: libdir may be substituted with sthing like $(exec_prefix)/lib # at this point and will go as such in the Makefile. Expansion will be diff --git a/src/qtgui/restable.cpp b/src/qtgui/restable.cpp index 604b871b..0a6f8400 100644 --- a/src/qtgui/restable.cpp +++ b/src/qtgui/restable.cpp @@ -590,7 +590,7 @@ void ResTable::init() splitter->setSizes(sizes); } - delete textBrowser; + deleteZ(textBrowser); m_detail = new ResTableDetailArea(this); m_detail->setReadOnly(true); m_detail->setUndoRedoEnabled(false); diff --git a/src/qtgui/searchclause_w.cpp b/src/qtgui/searchclause_w.cpp index 8036162f..60438fa7 100644 --- a/src/qtgui/searchclause_w.cpp +++ b/src/qtgui/searchclause_w.cpp @@ -60,14 +60,6 @@ SearchClauseW::SearchClauseW(QWidget* parent) connect(sTpCMB, SIGNAL(activated(int)), this, SLOT(tpChange(int))); } -/* - * Destroys the object and frees any allocated resources - */ -SearchClauseW::~SearchClauseW() -{ - // no need to delete child widgets, Qt does it all for us -} - /* * Sets the strings of the subwidgets using the current * language. diff --git a/src/qtgui/searchclause_w.h b/src/qtgui/searchclause_w.h index 01774a19..60cdb66e 100644 --- a/src/qtgui/searchclause_w.h +++ b/src/qtgui/searchclause_w.h @@ -35,7 +35,6 @@ class SearchClauseW : public QWidget public: SearchClauseW(QWidget* parent = 0); - ~SearchClauseW(); Rcl::SearchDataClause *getClause(); void setFromClause(Rcl::SearchDataClauseSimple *cl); void clear();