moved initial db open and possible message boxes from main.cpp to rclmain_w.cpp first post-init job to avoid random crashes apparently related to the dialogs being created before app.exec(). Exact cause not certain, but crashes gone...
This commit is contained in:
parent
8ddea418aa
commit
c09593f7db
@ -316,12 +316,8 @@ int main(int argc, char **argv)
|
|||||||
mainWindow->resize(s);
|
mainWindow->resize(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
mainWindow->sSearch->searchTypCMB->setCurrentItem(prefs.ssearchTyp);
|
|
||||||
mainWindow->sSearch->searchTypeChanged(prefs.ssearchTyp);
|
|
||||||
string dbdir = rclconfig->getDbDir();
|
string dbdir = rclconfig->getDbDir();
|
||||||
if (dbdir.empty()) {
|
if (dbdir.empty()) {
|
||||||
// Note: this will have to be replaced by a call to a
|
|
||||||
// configuration buildin dialog for initial configuration
|
|
||||||
QMessageBox::critical(0, "Recoll",
|
QMessageBox::critical(0, "Recoll",
|
||||||
app.translate("Main",
|
app.translate("Main",
|
||||||
"No db directory in configuration"));
|
"No db directory in configuration"));
|
||||||
@ -330,47 +326,11 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
rcldb = new Rcl::Db(rclconfig);
|
rcldb = new Rcl::Db(rclconfig);
|
||||||
|
|
||||||
bool needindexconfig = false;
|
|
||||||
if (!maybeOpenDb(reason)) {
|
|
||||||
|
|
||||||
switch (QMessageBox::
|
|
||||||
#if (QT_VERSION >= 0x030200)
|
|
||||||
question
|
|
||||||
#else
|
|
||||||
information
|
|
||||||
#endif
|
|
||||||
(0, "Recoll",
|
|
||||||
app.translate("Main", "Could not open database in ") +
|
|
||||||
QString::fromLocal8Bit(dbdir.c_str()) +
|
|
||||||
app.translate("Main",
|
|
||||||
".\n"
|
|
||||||
"Click Cancel if you want to edit the configuration file before indexation starts, or Ok to let it proceed."),
|
|
||||||
"Ok", "Cancel", 0, 0)) {
|
|
||||||
|
|
||||||
case 0: // Ok: indexing is going to start.
|
|
||||||
start_indexing(true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1: // Cancel
|
|
||||||
needindexconfig = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mainWindow->show();
|
mainWindow->show();
|
||||||
if (needindexconfig) {
|
QTimer::singleShot(0, mainWindow, SLOT(initDbOpen()));
|
||||||
startIndexingAfterConfig = 1;
|
|
||||||
mainWindow->showIndexConfig();
|
|
||||||
} else {
|
|
||||||
if (prefs.startWithAdvSearchOpen)
|
|
||||||
mainWindow->showAdvSearchDialog();
|
|
||||||
if (prefs.startWithSortToolOpen)
|
|
||||||
mainWindow->showSortDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Connect exit handlers etc.. Beware, apparently this must come
|
// Connect exit handlers etc.. Beware, apparently this must come
|
||||||
// after mainWindow->show() , else the QMessageBox above never
|
// after mainWindow->show()?
|
||||||
// returns.
|
|
||||||
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
|
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
|
||||||
app.connect(&app, SIGNAL(aboutToQuit()), mainWindow, SLOT(close()));
|
app.connect(&app, SIGNAL(aboutToQuit()), mainWindow, SLOT(close()));
|
||||||
|
|
||||||
@ -378,6 +338,8 @@ int main(int argc, char **argv)
|
|||||||
// something to do.
|
// something to do.
|
||||||
start_idxthread(*rclconfig);
|
start_idxthread(*rclconfig);
|
||||||
|
|
||||||
|
mainWindow->sSearch->searchTypCMB->setCurrentItem(prefs.ssearchTyp);
|
||||||
|
mainWindow->sSearch->searchTypeChanged(prefs.ssearchTyp);
|
||||||
if (op_flags & OPT_q) {
|
if (op_flags & OPT_q) {
|
||||||
SSearch::SSearchType stype;
|
SSearch::SSearchType stype;
|
||||||
if (op_flags & OPT_o) {
|
if (op_flags & OPT_o) {
|
||||||
@ -392,10 +354,7 @@ int main(int argc, char **argv)
|
|||||||
mainWindow->sSearch->searchTypCMB->setCurrentItem(int(stype));
|
mainWindow->sSearch->searchTypCMB->setCurrentItem(int(stype));
|
||||||
mainWindow->
|
mainWindow->
|
||||||
sSearch->setSearchString(QString::fromLocal8Bit(question.c_str()));
|
sSearch->setSearchString(QString::fromLocal8Bit(question.c_str()));
|
||||||
QTimer::singleShot(0, mainWindow->sSearch, SLOT(startSimpleSearch()));
|
|
||||||
}
|
}
|
||||||
// fprintf(stderr, "Go\n");
|
|
||||||
// Let's go
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -302,6 +302,54 @@ void RclMain::init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is called by a timer right after we come up. Try to open
|
||||||
|
// the database and talk to the user if we can't
|
||||||
|
void RclMain::initDbOpen()
|
||||||
|
{
|
||||||
|
bool needindexconfig = false;
|
||||||
|
bool nodb = false;
|
||||||
|
string reason;
|
||||||
|
if (!maybeOpenDb(reason)) {
|
||||||
|
nodb = true;
|
||||||
|
switch (QMessageBox::
|
||||||
|
#if (QT_VERSION >= 0x030200)
|
||||||
|
question
|
||||||
|
#else
|
||||||
|
information
|
||||||
|
#endif
|
||||||
|
(this, "Recoll",
|
||||||
|
qApp->translate("Main", "Could not open database in ") +
|
||||||
|
QString::fromLocal8Bit(rclconfig->getDbDir().c_str()) +
|
||||||
|
qApp->translate("Main",
|
||||||
|
".\n"
|
||||||
|
"Click Cancel if you want to edit the configuration file before indexation starts, or Ok to let it proceed."),
|
||||||
|
"Ok", "Cancel", 0, 0)) {
|
||||||
|
|
||||||
|
case 0: // Ok: indexing is going to start.
|
||||||
|
start_indexing(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: // Cancel
|
||||||
|
needindexconfig = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needindexconfig) {
|
||||||
|
startIndexingAfterConfig = 1;
|
||||||
|
showIndexConfig();
|
||||||
|
} else {
|
||||||
|
if (prefs.startWithAdvSearchOpen)
|
||||||
|
showAdvSearchDialog();
|
||||||
|
if (prefs.startWithSortToolOpen)
|
||||||
|
showSortDialog();
|
||||||
|
// If we have something in the search entry, it comes from a
|
||||||
|
// command line argument
|
||||||
|
if (!nodb && sSearch->hasSearchString())
|
||||||
|
QTimer::singleShot(0, sSearch, SLOT(startSimpleSearch()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RclMain::setStemLang(int id)
|
void RclMain::setStemLang(int id)
|
||||||
{
|
{
|
||||||
LOGDEB(("RclMain::setStemLang(%d)\n", id));
|
LOGDEB(("RclMain::setStemLang(%d)\n", id));
|
||||||
|
|||||||
@ -110,6 +110,7 @@ public slots:
|
|||||||
// Prefs menu about to show, set the checked lang entry
|
// Prefs menu about to show, set the checked lang entry
|
||||||
virtual void adjustPrefsMenu();
|
virtual void adjustPrefsMenu();
|
||||||
virtual void catgFilter(int);
|
virtual void catgFilter(int);
|
||||||
|
virtual void initDbOpen();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void stemLangChanged(const QString& lang);
|
void stemLangChanged(const QString& lang);
|
||||||
|
|||||||
@ -191,11 +191,17 @@ void SSearch::startSimpleSearch()
|
|||||||
RefCntr<Rcl::SearchData> rsdata(sdata);
|
RefCntr<Rcl::SearchData> rsdata(sdata);
|
||||||
emit startSearch(rsdata);
|
emit startSearch(rsdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSearch::setSearchString(const QString& txt)
|
void SSearch::setSearchString(const QString& txt)
|
||||||
{
|
{
|
||||||
queryText->setEditText(txt);
|
queryText->setEditText(txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SSearch::hasSearchString()
|
||||||
|
{
|
||||||
|
return !queryText->lineEdit()->text().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
void SSearch::setAnyTermMode()
|
void SSearch::setAnyTermMode()
|
||||||
{
|
{
|
||||||
searchTypCMB->setCurrentItem(SST_ANY);
|
searchTypCMB->setCurrentItem(SST_ANY);
|
||||||
|
|||||||
@ -61,6 +61,7 @@ public:
|
|||||||
virtual void setAnyTermMode();
|
virtual void setAnyTermMode();
|
||||||
virtual void completion();
|
virtual void completion();
|
||||||
virtual bool eventFilter(QObject *target, QEvent *event);
|
virtual bool eventFilter(QObject *target, QEvent *event);
|
||||||
|
virtual bool hasSearchString();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void searchTextChanged(const QString & text);
|
virtual void searchTextChanged(const QString & text);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user