fixed crash with autosearch caused by starting several simultaneous queries
This commit is contained in:
parent
7130edd5cb
commit
aba4f61e42
@ -108,6 +108,7 @@ void startManual(const string& helpindex)
|
||||
|
||||
bool maybeOpenDb(string &reason, bool force, bool *maindberror)
|
||||
{
|
||||
LOGDEB2(("maybeOpenDb: force %d\n", force));
|
||||
if (!rcldb) {
|
||||
reason = "Internal error: db not created";
|
||||
return false;
|
||||
|
||||
@ -769,7 +769,13 @@ void RclMain::rebuildIndex()
|
||||
// Start a db query and set the reslist docsource
|
||||
void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
|
||||
{
|
||||
LOGDEB(("RclMain::startSearch. Indexing %s\n", m_idxproc?"on":"off"));
|
||||
LOGDEB(("RclMain::startSearch. Indexing %s Active %d\n",
|
||||
m_idxproc?"on":"off", m_queryActive));
|
||||
if (m_queryActive) {
|
||||
LOGDEB(("startSearch: already active\n"));
|
||||
return;
|
||||
}
|
||||
m_queryActive = true;
|
||||
m_source = RefCntr<DocSequence>();
|
||||
|
||||
// The db may have been closed at the end of indexing
|
||||
@ -777,6 +783,7 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
|
||||
// If indexing is being performed, we reopen the db at each query.
|
||||
if (!maybeOpenDb(reason, m_idxproc != 0)) {
|
||||
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
|
||||
m_queryActive = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -818,9 +825,8 @@ class QueryThread : public QThread {
|
||||
|
||||
void RclMain::initiateQuery()
|
||||
{
|
||||
if (m_queryActive || m_source.isNull())
|
||||
if (m_source.isNull())
|
||||
return;
|
||||
m_queryActive = true;
|
||||
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
QueryThread qthr(m_source);
|
||||
|
||||
@ -36,6 +36,10 @@
|
||||
#include "wasatorcl.h"
|
||||
#include "rclhelp.h"
|
||||
|
||||
// Typing interval after which we consider starting autosearch: no sense to do
|
||||
// this is user is typing fast and continuously
|
||||
static const int strokeTimeoutMS = 250;
|
||||
|
||||
void SSearch::init()
|
||||
{
|
||||
// See enum above and keep in order !
|
||||
@ -103,12 +107,13 @@ void SSearch::searchTextChanged(const QString& text)
|
||||
if (prefs.ssearchAsYouType && !m_disableAutosearch &&
|
||||
!m_keystroke && m_tstartqs == qs) {
|
||||
m_disableAutosearch = true;
|
||||
LOGDEB0(("SSearch::searchTextChanged: autosearch\n"));
|
||||
string s;
|
||||
int cs = partialWord(s);
|
||||
LOGDEB0(("SSearch::searchTextChanged: autosearch. cs %d s [%s]\n",
|
||||
cs, s.c_str()));
|
||||
if (cs < 0) {
|
||||
startSimpleSearch();
|
||||
} else if (!m_stroketimeout->isActive()) {
|
||||
} else if (!m_stroketimeout->isActive() && s.size() >= 2) {
|
||||
s = qs2utf8s(queryText->currentText());
|
||||
s += "*";
|
||||
startSimpleSearch(s, 20);
|
||||
@ -328,6 +333,8 @@ void SSearch::setAnyTermMode()
|
||||
searchTypCMB->setCurrentIndex(SST_ANY);
|
||||
}
|
||||
|
||||
// If text does not end with space, return last (partial) word and >0
|
||||
// else return -1
|
||||
int SSearch::partialWord(string& s)
|
||||
{
|
||||
// Extract last word in text
|
||||
@ -648,7 +655,7 @@ bool SSearch::eventFilter(QObject *target, QEvent *event)
|
||||
QString qs = queryText->currentText();
|
||||
LOGDEB0(("SSearch::eventFilter: start timer, qs [%s]\n",
|
||||
qs2utf8s(qs).c_str()));
|
||||
m_stroketimeout->start(200);
|
||||
m_stroketimeout->start(strokeTimeoutMS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user