mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
fix: crash on quit while fullindex is creating
This commit is contained in:
parent
bf625dc550
commit
2d8ba54a1d
|
@ -36,6 +36,7 @@ void Indexing::run()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
timerThread->start();
|
||||||
// First iteration - dictionaries with no more MaxDictionarySizeForFastSearch articles
|
// First iteration - dictionaries with no more MaxDictionarySizeForFastSearch articles
|
||||||
for( size_t x = 0; x < dictionaries.size(); x++ )
|
for( size_t x = 0; x < dictionaries.size(); x++ )
|
||||||
{
|
{
|
||||||
|
@ -63,6 +64,9 @@ void Indexing::run()
|
||||||
dictionaries.at( x )->makeFTSIndex( isCancelled, false );
|
dictionaries.at( x )->makeFTSIndex( isCancelled, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timerThread->quit();
|
||||||
|
timerThread->wait();
|
||||||
}
|
}
|
||||||
catch( std::exception &ex )
|
catch( std::exception &ex )
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,28 +89,15 @@ public:
|
||||||
timerThread(new QThread(this))
|
timerThread(new QThread(this))
|
||||||
{
|
{
|
||||||
connect(timer, &QTimer::timeout, this, &Indexing::timeout);
|
connect(timer, &QTimer::timeout, this, &Indexing::timeout);
|
||||||
// timer->start(2000);
|
|
||||||
timer->moveToThread(timerThread);
|
timer->moveToThread(timerThread);
|
||||||
connect(timerThread, &QThread::started, timer, [this](){timer->start(2000);});
|
connect(timerThread, &QThread::started, timer, [this](){timer->start(2000);});
|
||||||
connect(timerThread, &QThread::finished, timer, &QTimer::stop);
|
connect(timerThread, &QThread::finished, timer, &QTimer::stop);
|
||||||
timerThread->start();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~Indexing()
|
~Indexing()
|
||||||
{
|
{
|
||||||
if(timerThread){
|
|
||||||
qInfo()<<"delete thread";
|
|
||||||
timerThread->quit();
|
|
||||||
timerThread->wait();
|
|
||||||
delete timerThread;
|
|
||||||
timerThread = nullptr;
|
|
||||||
}
|
|
||||||
if(timer){
|
|
||||||
qInfo()<<"delete timer";
|
|
||||||
delete timer;
|
|
||||||
timer = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit sendNowIndexingName( QString() );
|
emit sendNowIndexingName( QString() );
|
||||||
hasExited.release();
|
hasExited.release();
|
||||||
|
|
Loading…
Reference in a new issue