GUI multiple clicks crash: make sure the GUI cant reenter the db
This commit is contained in:
parent
34d12cc212
commit
53845645fb
8 changed files with 34 additions and 27 deletions
|
@ -777,6 +777,7 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata, bool issimple)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_queryActive = true;
|
m_queryActive = true;
|
||||||
|
restable->setEnabled(false);
|
||||||
m_source = RefCntr<DocSequence>();
|
m_source = RefCntr<DocSequence>();
|
||||||
|
|
||||||
m_searchIsSimple = issimple;
|
m_searchIsSimple = issimple;
|
||||||
|
@ -787,6 +788,7 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata, bool issimple)
|
||||||
if (!maybeOpenDb(reason, m_idxproc != 0)) {
|
if (!maybeOpenDb(reason, m_idxproc != 0)) {
|
||||||
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
|
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
|
||||||
m_queryActive = false;
|
m_queryActive = false;
|
||||||
|
restable->setEnabled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -876,6 +878,7 @@ void RclMain::initiateQuery()
|
||||||
statusBar()->showMessage(msg, 0);
|
statusBar()->showMessage(msg, 0);
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
m_queryActive = false;
|
m_queryActive = false;
|
||||||
|
restable->setEnabled(true);
|
||||||
emit(resultsReady());
|
emit(resultsReady());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "debuglog.h"
|
#include "debuglog.h"
|
||||||
#include "internfile.h"
|
#include "internfile.h"
|
||||||
|
|
||||||
|
PTMutexInit DocSequence::o_dblock;
|
||||||
string DocSequence::o_sort_trans;
|
string DocSequence::o_sort_trans;
|
||||||
string DocSequence::o_filt_trans;
|
string DocSequence::o_filt_trans;
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ bool DocSequence::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc)
|
||||||
LOGERR(("DocSequence::getEnclosing: no db\n"));
|
LOGERR(("DocSequence::getEnclosing: no db\n"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
PTMutexLocker locker(o_dblock);
|
||||||
string udi;
|
string udi;
|
||||||
if (!FileInterner::getEnclosingUDI(doc, udi))
|
if (!FileInterner::getEnclosingUDI(doc, udi))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "rcldoc.h"
|
#include "rcldoc.h"
|
||||||
#include "refcntr.h"
|
#include "refcntr.h"
|
||||||
#include "hldata.h"
|
#include "hldata.h"
|
||||||
|
#include "ptmutex.h"
|
||||||
|
|
||||||
// Need this for the "Snippet" class def.
|
// Need this for the "Snippet" class def.
|
||||||
#include "rclquery.h"
|
#include "rclquery.h"
|
||||||
|
@ -160,10 +161,11 @@ class DocSequence {
|
||||||
o_filt_trans = filt;
|
o_filt_trans = filt;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Rcl::Db *getDb() = 0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
friend class DocSeqModifier;
|
||||||
|
virtual Rcl::Db *getDb() = 0;
|
||||||
|
static PTMutexInit o_dblock;
|
||||||
static std::string o_sort_trans;
|
static std::string o_sort_trans;
|
||||||
static std::string o_filt_trans;
|
static std::string o_filt_trans;
|
||||||
std::string m_reason;
|
std::string m_reason;
|
||||||
|
@ -242,6 +244,7 @@ public:
|
||||||
return m_seq;
|
return m_seq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
virtual Rcl::Db *getDb()
|
virtual Rcl::Db *getDb()
|
||||||
{
|
{
|
||||||
if (m_seq.isNull())
|
if (m_seq.isNull())
|
||||||
|
@ -249,8 +252,6 @@ public:
|
||||||
return m_seq->getDb();
|
return m_seq->getDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
RefCntr<DocSequence> m_seq;
|
RefCntr<DocSequence> m_seq;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,6 @@ DocSequenceDb::DocSequenceDb(RefCntr<Rcl::Query> q, const string &t,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DocSequenceDb::~DocSequenceDb()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DocSequenceDb::getTerms(HighlightData& hld)
|
void DocSequenceDb::getTerms(HighlightData& hld)
|
||||||
{
|
{
|
||||||
m_fsdata->getTerms(hld);
|
m_fsdata->getTerms(hld);
|
||||||
|
@ -54,6 +50,7 @@ string DocSequenceDb::getDescription()
|
||||||
|
|
||||||
bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, string *sh)
|
bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, string *sh)
|
||||||
{
|
{
|
||||||
|
PTMutexLocker locker(o_dblock);
|
||||||
if (!setQuery())
|
if (!setQuery())
|
||||||
return false;
|
return false;
|
||||||
if (sh) sh->erase();
|
if (sh) sh->erase();
|
||||||
|
@ -62,6 +59,7 @@ bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, string *sh)
|
||||||
|
|
||||||
int DocSequenceDb::getResCnt()
|
int DocSequenceDb::getResCnt()
|
||||||
{
|
{
|
||||||
|
PTMutexLocker locker(o_dblock);
|
||||||
if (!setQuery())
|
if (!setQuery())
|
||||||
return false;
|
return false;
|
||||||
if (m_rescnt < 0) {
|
if (m_rescnt < 0) {
|
||||||
|
@ -77,6 +75,7 @@ static const string cstr_mre("[...]");
|
||||||
bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<Rcl::Snippet>& vpabs)
|
bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<Rcl::Snippet>& vpabs)
|
||||||
{
|
{
|
||||||
LOGDEB(("DocSequenceDb::getAbstract/pair\n"));
|
LOGDEB(("DocSequenceDb::getAbstract/pair\n"));
|
||||||
|
PTMutexLocker locker(o_dblock);
|
||||||
if (!setQuery())
|
if (!setQuery())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -107,6 +106,7 @@ bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<Rcl::Snippet>& vpabs)
|
||||||
|
|
||||||
bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<string>& vabs)
|
bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<string>& vabs)
|
||||||
{
|
{
|
||||||
|
PTMutexLocker locker(o_dblock);
|
||||||
if (!setQuery())
|
if (!setQuery())
|
||||||
return false;
|
return false;
|
||||||
if (m_q->whatDb() &&
|
if (m_q->whatDb() &&
|
||||||
|
@ -120,6 +120,7 @@ bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<string>& vabs)
|
||||||
|
|
||||||
int DocSequenceDb::getFirstMatchPage(Rcl::Doc &doc, string& term)
|
int DocSequenceDb::getFirstMatchPage(Rcl::Doc &doc, string& term)
|
||||||
{
|
{
|
||||||
|
PTMutexLocker locker(o_dblock);
|
||||||
if (!setQuery())
|
if (!setQuery())
|
||||||
return false;
|
return false;
|
||||||
if (m_q->whatDb()) {
|
if (m_q->whatDb()) {
|
||||||
|
@ -135,6 +136,7 @@ Rcl::Db *DocSequenceDb::getDb()
|
||||||
|
|
||||||
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
|
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
|
||||||
{
|
{
|
||||||
|
PTMutexLocker locker(o_dblock);
|
||||||
if (!setQuery())
|
if (!setQuery())
|
||||||
return list<string>();
|
return list<string>();
|
||||||
vector<string> v = m_q->expand(doc);
|
vector<string> v = m_q->expand(doc);
|
||||||
|
@ -149,13 +151,15 @@ string DocSequenceDb::title()
|
||||||
else if (!m_isFiltered && m_isSorted)
|
else if (!m_isFiltered && m_isSorted)
|
||||||
qual = string(" (") + o_sort_trans + string(")");
|
qual = string(" (") + o_sort_trans + string(")");
|
||||||
else if (m_isFiltered && m_isSorted)
|
else if (m_isFiltered && m_isSorted)
|
||||||
qual = string(" (") + o_sort_trans + string(",") + o_filt_trans + string(")");
|
qual = string(" (") + o_sort_trans + string(",") + o_filt_trans +
|
||||||
|
string(")");
|
||||||
return DocSequence::title() + qual;
|
return DocSequence::title() + qual;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
|
bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
|
||||||
{
|
{
|
||||||
LOGDEB(("DocSequenceDb::setFiltSpec\n"));
|
LOGDEB(("DocSequenceDb::setFiltSpec\n"));
|
||||||
|
PTMutexLocker locker(o_dblock);
|
||||||
if (fs.isNotNull()) {
|
if (fs.isNotNull()) {
|
||||||
// We build a search spec by adding a filtering layer to the base one.
|
// We build a search spec by adding a filtering layer to the base one.
|
||||||
m_fsdata = RefCntr<Rcl::SearchData>(
|
m_fsdata = RefCntr<Rcl::SearchData>(
|
||||||
|
@ -204,6 +208,7 @@ bool DocSequenceDb::setSortSpec(const DocSeqSortSpec &spec)
|
||||||
{
|
{
|
||||||
LOGDEB(("DocSequenceDb::setSortSpec: fld [%s] %s\n",
|
LOGDEB(("DocSequenceDb::setSortSpec: fld [%s] %s\n",
|
||||||
spec.field.c_str(), spec.desc ? "desc" : "asc"));
|
spec.field.c_str(), spec.desc ? "desc" : "asc"));
|
||||||
|
PTMutexLocker locker(o_dblock);
|
||||||
if (spec.isNotNull()) {
|
if (spec.isNotNull()) {
|
||||||
m_q->setSortBy(spec.field, !spec.desc);
|
m_q->setSortBy(spec.field, !spec.desc);
|
||||||
m_isSorted = true;
|
m_isSorted = true;
|
||||||
|
@ -234,6 +239,7 @@ bool DocSequenceDb::setQuery()
|
||||||
bool DocSequenceDb::docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups)
|
bool DocSequenceDb::docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups)
|
||||||
{
|
{
|
||||||
if (m_q->whatDb()) {
|
if (m_q->whatDb()) {
|
||||||
|
PTMutexLocker locker(o_dblock);
|
||||||
return m_q->whatDb()->docDups(doc, dups);
|
return m_q->whatDb()->docDups(doc, dups);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -27,7 +27,7 @@ class DocSequenceDb : public DocSequence {
|
||||||
public:
|
public:
|
||||||
DocSequenceDb(RefCntr<Rcl::Query> q, const string &t,
|
DocSequenceDb(RefCntr<Rcl::Query> q, const string &t,
|
||||||
RefCntr<Rcl::SearchData> sdata);
|
RefCntr<Rcl::SearchData> sdata);
|
||||||
virtual ~DocSequenceDb();
|
virtual ~DocSequenceDb() {}
|
||||||
virtual bool getDoc(int num, Rcl::Doc &doc, string * = 0);
|
virtual bool getDoc(int num, Rcl::Doc &doc, string * = 0);
|
||||||
virtual int getResCnt();
|
virtual int getResCnt();
|
||||||
virtual void getTerms(HighlightData& hld);
|
virtual void getTerms(HighlightData& hld);
|
||||||
|
@ -38,7 +38,6 @@ class DocSequenceDb : public DocSequence {
|
||||||
|
|
||||||
virtual bool getAbstract(Rcl::Doc &doc, vector<string>&);
|
virtual bool getAbstract(Rcl::Doc &doc, vector<string>&);
|
||||||
virtual int getFirstMatchPage(Rcl::Doc&, std::string& term);
|
virtual int getFirstMatchPage(Rcl::Doc&, std::string& term);
|
||||||
virtual Rcl::Db *getDb();
|
|
||||||
virtual bool docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups);
|
virtual bool docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups);
|
||||||
virtual string getDescription();
|
virtual string getDescription();
|
||||||
virtual list<string> expand(Rcl::Doc &doc);
|
virtual list<string> expand(Rcl::Doc &doc);
|
||||||
|
@ -58,6 +57,8 @@ class DocSequenceDb : public DocSequence {
|
||||||
}
|
}
|
||||||
virtual string title();
|
virtual string title();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual Rcl::Db *getDb();
|
||||||
private:
|
private:
|
||||||
RefCntr<Rcl::Query> m_q;
|
RefCntr<Rcl::Query> m_q;
|
||||||
RefCntr<Rcl::SearchData> m_sdata;
|
RefCntr<Rcl::SearchData> m_sdata;
|
||||||
|
|
|
@ -44,10 +44,6 @@ class DocSequenceDocs : public DocSequence {
|
||||||
doc = m_docs[num];
|
doc = m_docs[num];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual Rcl::Db *getDb()
|
|
||||||
{
|
|
||||||
return m_db;
|
|
||||||
}
|
|
||||||
virtual int getResCnt()
|
virtual int getResCnt()
|
||||||
{
|
{
|
||||||
return m_docs.size();
|
return m_docs.size();
|
||||||
|
@ -60,6 +56,11 @@ class DocSequenceDocs : public DocSequence {
|
||||||
{
|
{
|
||||||
m_description = desc;
|
m_description = desc;
|
||||||
}
|
}
|
||||||
|
protected:
|
||||||
|
virtual Rcl::Db *getDb()
|
||||||
|
{
|
||||||
|
return m_db;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
Rcl::Db *m_db;
|
Rcl::Db *m_db;
|
||||||
string m_description;
|
string m_description;
|
||||||
|
|
|
@ -48,10 +48,11 @@ class DocSequenceHistory : public DocSequence {
|
||||||
virtual ~DocSequenceHistory() {}
|
virtual ~DocSequenceHistory() {}
|
||||||
|
|
||||||
virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0);
|
virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0);
|
||||||
virtual Rcl::Db *getDb();
|
|
||||||
virtual int getResCnt();
|
virtual int getResCnt();
|
||||||
virtual string getDescription() {return m_description;}
|
virtual string getDescription() {return m_description;}
|
||||||
void setDescription(const string& desc) {m_description = desc;}
|
void setDescription(const string& desc) {m_description = desc;}
|
||||||
|
protected:
|
||||||
|
virtual Rcl::Db *getDb();
|
||||||
private:
|
private:
|
||||||
Rcl::Db *m_db;
|
Rcl::Db *m_db;
|
||||||
RclDynConf *m_hist;
|
RclDynConf *m_hist;
|
||||||
|
|
|
@ -224,7 +224,7 @@ public:
|
||||||
virtual bool toNativeQuery(Rcl::Db &db, void *) = 0;
|
virtual bool toNativeQuery(Rcl::Db &db, void *) = 0;
|
||||||
bool isFileName() const {return m_tp == SCLT_FILENAME ? true: false;}
|
bool isFileName() const {return m_tp == SCLT_FILENAME ? true: false;}
|
||||||
virtual std::string getReason() const {return m_reason;}
|
virtual std::string getReason() const {return m_reason;}
|
||||||
virtual void getTerms(HighlightData & hldata) const = 0;
|
virtual void getTerms(HighlightData&) const {}
|
||||||
|
|
||||||
SClType getTp() const
|
SClType getTp() const
|
||||||
{
|
{
|
||||||
|
@ -382,10 +382,6 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void getTerms(HighlightData&) const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool toNativeQuery(Rcl::Db &, void *);
|
virtual bool toNativeQuery(Rcl::Db &, void *);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -423,10 +419,6 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void getTerms(HighlightData&) const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool toNativeQuery(Rcl::Db &, void *);
|
virtual bool toNativeQuery(Rcl::Db &, void *);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue