statically declared shortcut caused crash during children delete in qapp::exit. Small related cleanups

This commit is contained in:
Jean-Francois Dockes 2020-06-14 18:06:31 +02:00
parent 66845a4148
commit adf0a7a848
9 changed files with 24 additions and 50 deletions

View File

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

View File

@ -203,23 +203,15 @@ void RclMain::periodic100()
}
// Possibly cleanup the dead viewers
for (vector<ExecCmd*>::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<ExecCmd*> v;
for (vector<ExecCmd*>::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

View File

@ -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<Rcl::Doc> 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);

View File

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

View File

@ -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<ExecCmd*> m_viewers;
ExecCmd *m_idxproc{0}; // Indexing process

View File

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

View File

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

View File

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

View File

@ -35,7 +35,6 @@ class SearchClauseW : public QWidget
public:
SearchClauseW(QWidget* parent = 0);
~SearchClauseW();
Rcl::SearchDataClause *getClause();
void setFromClause(Rcl::SearchDataClauseSimple *cl);
void clear();