Use a shared_ptr to make sure that the rcldb referenced by the current query remains valid
This commit is contained in:
+4
-4
@@ -81,7 +81,7 @@ void deleteAllTempFiles()
|
||||
Uncomp::clearcache();
|
||||
}
|
||||
|
||||
Rcl::Db *rcldb;
|
||||
std::shared_ptr<Rcl::Db> rcldb;
|
||||
int recollNeedsExit;
|
||||
RclMain *mainWindow;
|
||||
|
||||
@@ -96,8 +96,7 @@ bool maybeOpenDb(string &reason, bool force, bool *maindberror)
|
||||
LOGDEB2("maybeOpenDb: force " << force << "\n");
|
||||
|
||||
if (force) {
|
||||
delete rcldb;
|
||||
rcldb = new Rcl::Db(theconfig);
|
||||
rcldb = std::shared_ptr<Rcl::Db>(new Rcl::Db(theconfig));
|
||||
}
|
||||
rcldb->rmQueryDb("");
|
||||
for (const auto& dbdir : prefs.activeExtraDbs) {
|
||||
@@ -142,10 +141,11 @@ bool getStemLangs(vector<string>& vlangs)
|
||||
}
|
||||
}
|
||||
|
||||
// This is never called because we _Exit() in rclmain_w.cpp
|
||||
static void recollCleanup()
|
||||
{
|
||||
LOGDEB2("recollCleanup: closing database\n" );
|
||||
deleteZ(rcldb);
|
||||
rcldb.reset();
|
||||
deleteZ(theconfig);
|
||||
|
||||
deleteAllTempFiles();
|
||||
|
||||
@@ -859,7 +859,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
|
||||
|
||||
|
||||
// Enter document in document history
|
||||
historyEnterDoc(rcldb, g_dynconf, idoc);
|
||||
historyEnterDoc(rcldb.get(), g_dynconf, idoc);
|
||||
|
||||
editor->setFocus();
|
||||
emit(previewExposed(this, m_searchId, docnum));
|
||||
|
||||
@@ -67,10 +67,10 @@ void RclMain::viewUrl()
|
||||
return;
|
||||
|
||||
// StartNativeViewer needs a db source to call getEnclosing() on.
|
||||
Rcl::Query *query = new Rcl::Query(rcldb);
|
||||
DocSequenceDb *src =
|
||||
new DocSequenceDb(std::shared_ptr<Rcl::Query>(query), "",
|
||||
std::shared_ptr<Rcl::SearchData>(new Rcl::SearchData));
|
||||
Rcl::Query *query = new Rcl::Query(rcldb.get());
|
||||
DocSequenceDb *src = new DocSequenceDb(
|
||||
rcldb, std::shared_ptr<Rcl::Query>(query), "",
|
||||
std::shared_ptr<Rcl::SearchData>(new Rcl::SearchData));
|
||||
m_source = std::shared_ptr<DocSequence>(src);
|
||||
|
||||
|
||||
@@ -458,7 +458,7 @@ void RclMain::execViewer(const map<string, string>& subs, bool enterHistory,
|
||||
}
|
||||
|
||||
if (enterHistory)
|
||||
historyEnterDoc(rcldb, g_dynconf, doc);
|
||||
historyEnterDoc(rcldb.get(), g_dynconf, doc);
|
||||
|
||||
// Do the zeitgeist thing
|
||||
zg_send_event(ZGSEND_OPEN, doc);
|
||||
|
||||
@@ -736,12 +736,12 @@ void RclMain::startSearch(std::shared_ptr<Rcl::SearchData> sdata, bool issimple)
|
||||
rcldb->setSynGroupsFile("");
|
||||
}
|
||||
|
||||
Rcl::Query *query = new Rcl::Query(rcldb);
|
||||
Rcl::Query *query = new Rcl::Query(rcldb.get());
|
||||
query->setCollapseDuplicates(prefs.collapseDuplicates);
|
||||
|
||||
curPreview = 0;
|
||||
DocSequenceDb *src =
|
||||
new DocSequenceDb(std::shared_ptr<Rcl::Query>(query),
|
||||
new DocSequenceDb(rcldb, std::shared_ptr<Rcl::Query>(query),
|
||||
string(tr("Query results").toUtf8()), sdata);
|
||||
src->setAbstractParams(prefs.queryBuildAbstract,
|
||||
prefs.queryReplaceAbstract);
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@
|
||||
#define _RECOLL_H_INCLUDED_
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include "rclconfig.h"
|
||||
#include "rcldb.h"
|
||||
@@ -40,7 +41,7 @@ extern TempFile *rememberTempFile(TempFile);
|
||||
extern void forgetTempFile(string &fn);
|
||||
extern void deleteAllTempFiles();
|
||||
|
||||
extern Rcl::Db *rcldb;
|
||||
extern std::shared_ptr<Rcl::Db> rcldb;
|
||||
extern int recollNeedsExit;
|
||||
extern void startManual(const string& helpindex);
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ void SpellW::showStats()
|
||||
string q = string("mime:") + *it;
|
||||
Rcl::SearchData *sd = wasaStringToRcl(theconfig, "", q, reason);
|
||||
std::shared_ptr<Rcl::SearchData> rq(sd);
|
||||
Rcl::Query query(rcldb);
|
||||
Rcl::Query query(rcldb.get());
|
||||
if (!query.setQuery(rq)) {
|
||||
LOGERR("Query setup failed: " << (query.getReason()) << "" );
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user