mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
concurrent run will crash application
This commit is contained in:
parent
6ff042d56f
commit
bd02d65ecc
12
dsl.cc
12
dsl.cc
|
@ -56,6 +56,8 @@
|
||||||
// For SVG handling
|
// For SVG handling
|
||||||
#include <QtSvg/QSvgRenderer>
|
#include <QtSvg/QSvgRenderer>
|
||||||
|
|
||||||
|
#include <QtConcurrent>
|
||||||
|
|
||||||
#include "utils.hh"
|
#include "utils.hh"
|
||||||
|
|
||||||
namespace Dsl {
|
namespace Dsl {
|
||||||
|
@ -1561,6 +1563,7 @@ class DslArticleRequest: public Dictionary::DataRequest
|
||||||
|
|
||||||
QAtomicInt isCancelled;
|
QAtomicInt isCancelled;
|
||||||
QSemaphore hasExited;
|
QSemaphore hasExited;
|
||||||
|
QFuture< void > f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -1569,7 +1572,8 @@ public:
|
||||||
DslDictionary & dict_, bool ignoreDiacritics_ ):
|
DslDictionary & dict_, bool ignoreDiacritics_ ):
|
||||||
word( word_ ), alts( alts_ ), dict( dict_ ), ignoreDiacritics( ignoreDiacritics_ )
|
word( word_ ), alts( alts_ ), dict( dict_ ), ignoreDiacritics( ignoreDiacritics_ )
|
||||||
{
|
{
|
||||||
QThreadPool::globalInstance()->start( [ this ]() { this->run(); } );
|
f = QtConcurrent::run( [ this ]() { this->run(); } );
|
||||||
|
// QThreadPool::globalInstance()->start( [ this ]() { this->run(); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
@ -1582,6 +1586,7 @@ public:
|
||||||
~DslArticleRequest()
|
~DslArticleRequest()
|
||||||
{
|
{
|
||||||
isCancelled.ref();
|
isCancelled.ref();
|
||||||
|
f.waitForFinished();
|
||||||
//hasExited.acquire();
|
//hasExited.acquire();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1733,6 +1738,7 @@ class DslResourceRequest: public Dictionary::DataRequest
|
||||||
|
|
||||||
QAtomicInt isCancelled;
|
QAtomicInt isCancelled;
|
||||||
QSemaphore hasExited;
|
QSemaphore hasExited;
|
||||||
|
QFuture< void > f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -1741,7 +1747,8 @@ public:
|
||||||
dict( dict_ ),
|
dict( dict_ ),
|
||||||
resourceName( resourceName_ )
|
resourceName( resourceName_ )
|
||||||
{
|
{
|
||||||
QThreadPool::globalInstance()->start( [ this ]() { this->run(); } );
|
f = QtConcurrent::run( [ this ]() { this->run(); } );
|
||||||
|
// QThreadPool::globalInstance()->start( [ this ]() { this->run(); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
@ -1754,6 +1761,7 @@ public:
|
||||||
~DslResourceRequest()
|
~DslResourceRequest()
|
||||||
{
|
{
|
||||||
isCancelled.ref();
|
isCancelled.ref();
|
||||||
|
f.waitForFinished();
|
||||||
//hasExited.acquire();
|
//hasExited.acquire();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
10
epwing.cc
10
epwing.cc
|
@ -10,6 +10,7 @@
|
||||||
#include <QSemaphore>
|
#include <QSemaphore>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <QtConcurrent>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -461,6 +462,7 @@ class EpwingArticleRequest: public Dictionary::DataRequest
|
||||||
|
|
||||||
QAtomicInt isCancelled;
|
QAtomicInt isCancelled;
|
||||||
QSemaphore hasExited;
|
QSemaphore hasExited;
|
||||||
|
QFuture< void > f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -469,8 +471,9 @@ public:
|
||||||
EpwingDictionary & dict_, bool ignoreDiacritics_ ):
|
EpwingDictionary & dict_, bool ignoreDiacritics_ ):
|
||||||
word( word_ ), alts( alts_ ), dict( dict_ ), ignoreDiacritics( ignoreDiacritics_ )
|
word( word_ ), alts( alts_ ), dict( dict_ ), ignoreDiacritics( ignoreDiacritics_ )
|
||||||
{
|
{
|
||||||
QThreadPool::globalInstance()->start(
|
f = QtConcurrent::run( [ this ]() { this->run(); } );
|
||||||
new EpwingArticleRequestRunnable( *this, hasExited ) );
|
// QThreadPool::globalInstance()->start(
|
||||||
|
// new EpwingArticleRequestRunnable( *this, hasExited ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(); // Run from another thread by EpwingArticleRequestRunnable
|
void run(); // Run from another thread by EpwingArticleRequestRunnable
|
||||||
|
@ -483,7 +486,8 @@ public:
|
||||||
~EpwingArticleRequest()
|
~EpwingArticleRequest()
|
||||||
{
|
{
|
||||||
isCancelled.ref();
|
isCancelled.ref();
|
||||||
hasExited.acquire();
|
f.waitForFinished();
|
||||||
|
// hasExited.acquire();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QRunnable>
|
#include <QRunnable>
|
||||||
#include <QSemaphore>
|
#include <QSemaphore>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QtConcurrent>
|
||||||
|
|
||||||
#include "dictionary.hh"
|
#include "dictionary.hh"
|
||||||
#include "btreeidx.hh"
|
#include "btreeidx.hh"
|
||||||
|
@ -83,6 +84,7 @@ class FTSResultsRequest : public Dictionary::DataRequest
|
||||||
QAtomicInt isCancelled;
|
QAtomicInt isCancelled;
|
||||||
|
|
||||||
QAtomicInt results;
|
QAtomicInt results;
|
||||||
|
QFuture< void > f;
|
||||||
|
|
||||||
QList< FTS::FtsHeadword > * foundHeadwords;
|
QList< FTS::FtsHeadword > * foundHeadwords;
|
||||||
|
|
||||||
|
@ -135,7 +137,8 @@ public:
|
||||||
|
|
||||||
foundHeadwords = new QList< FTS::FtsHeadword >;
|
foundHeadwords = new QList< FTS::FtsHeadword >;
|
||||||
results = 0;
|
results = 0;
|
||||||
QThreadPool::globalInstance()->start( [ this ]() { this->run(); }, -100 );
|
f = QtConcurrent::run( [ this ]() { this->run(); } );
|
||||||
|
// QThreadPool::globalInstance()->start( [ this ]() { this->run(); }, -100 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
@ -148,6 +151,7 @@ public:
|
||||||
~FTSResultsRequest()
|
~FTSResultsRequest()
|
||||||
{
|
{
|
||||||
isCancelled.ref();
|
isCancelled.ref();
|
||||||
|
f.waitForFinished();
|
||||||
if( foundHeadwords )
|
if( foundHeadwords )
|
||||||
delete foundHeadwords;
|
delete foundHeadwords;
|
||||||
}
|
}
|
||||||
|
|
11
mdx.cc
11
mdx.cc
|
@ -43,6 +43,7 @@
|
||||||
#include "tiff.hh"
|
#include "tiff.hh"
|
||||||
#include "utils.hh"
|
#include "utils.hh"
|
||||||
#include "base/globalregex.hh"
|
#include "base/globalregex.hh"
|
||||||
|
#include <QtConcurrent>
|
||||||
|
|
||||||
namespace Mdx
|
namespace Mdx
|
||||||
{
|
{
|
||||||
|
@ -533,6 +534,7 @@ class MdxArticleRequest: public Dictionary::DataRequest
|
||||||
|
|
||||||
QAtomicInt isCancelled;
|
QAtomicInt isCancelled;
|
||||||
QSemaphore hasExited;
|
QSemaphore hasExited;
|
||||||
|
QFuture< void > f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -545,7 +547,8 @@ public:
|
||||||
dict( dict_ ),
|
dict( dict_ ),
|
||||||
ignoreDiacritics( ignoreDiacritics_ )
|
ignoreDiacritics( ignoreDiacritics_ )
|
||||||
{
|
{
|
||||||
QThreadPool::globalInstance()->start( [ this ]() { this->run(); } );
|
f = QtConcurrent::run( [ this ]() { this->run(); } );
|
||||||
|
// QThreadPool::globalInstance()->start( );
|
||||||
}
|
}
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
@ -558,6 +561,7 @@ public:
|
||||||
~MdxArticleRequest()
|
~MdxArticleRequest()
|
||||||
{
|
{
|
||||||
isCancelled.ref();
|
isCancelled.ref();
|
||||||
|
f.waitForFinished();
|
||||||
// hasExited.acquire();
|
// hasExited.acquire();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -687,6 +691,7 @@ class MddResourceRequest: public Dictionary::DataRequest
|
||||||
wstring resourceName;
|
wstring resourceName;
|
||||||
QAtomicInt isCancelled;
|
QAtomicInt isCancelled;
|
||||||
QSemaphore hasExited;
|
QSemaphore hasExited;
|
||||||
|
QFuture< void > f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -695,7 +700,8 @@ public:
|
||||||
dict( dict_ ),
|
dict( dict_ ),
|
||||||
resourceName( Utf8::decode( resourceName_ ) )
|
resourceName( Utf8::decode( resourceName_ ) )
|
||||||
{
|
{
|
||||||
QThreadPool::globalInstance()->start( [ this ]() { this->run(); } );
|
f = QtConcurrent::run( [ this ]() { this->run(); } );
|
||||||
|
// QThreadPool::globalInstance()->start( [ this ]() { this->run(); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
@ -708,6 +714,7 @@ public:
|
||||||
~MddResourceRequest()
|
~MddResourceRequest()
|
||||||
{
|
{
|
||||||
isCancelled.ref();
|
isCancelled.ref();
|
||||||
|
f.waitForFinished();
|
||||||
//hasExited.acquire();
|
//hasExited.acquire();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
11
zim.cc
11
zim.cc
|
@ -41,6 +41,7 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <QtConcurrent>
|
||||||
|
|
||||||
namespace Zim {
|
namespace Zim {
|
||||||
|
|
||||||
|
@ -1248,6 +1249,7 @@ class ZimArticleRequest: public Dictionary::DataRequest
|
||||||
|
|
||||||
QAtomicInt isCancelled;
|
QAtomicInt isCancelled;
|
||||||
QSemaphore hasExited;
|
QSemaphore hasExited;
|
||||||
|
QFuture< void > f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -1256,7 +1258,8 @@ public:
|
||||||
ZimDictionary & dict_, bool ignoreDiacritics_ ):
|
ZimDictionary & dict_, bool ignoreDiacritics_ ):
|
||||||
word( word_ ), alts( alts_ ), dict( dict_ ), ignoreDiacritics( ignoreDiacritics_ )
|
word( word_ ), alts( alts_ ), dict( dict_ ), ignoreDiacritics( ignoreDiacritics_ )
|
||||||
{
|
{
|
||||||
QThreadPool::globalInstance()->start( [ this ]() { this->run(); } );
|
f = QtConcurrent::run( [ this ]() { this->run(); } );
|
||||||
|
// QThreadPool::globalInstance()->start( [ this ]() { this->run(); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
@ -1269,6 +1272,7 @@ public:
|
||||||
~ZimArticleRequest()
|
~ZimArticleRequest()
|
||||||
{
|
{
|
||||||
isCancelled.ref();
|
isCancelled.ref();
|
||||||
|
f.waitForFinished();
|
||||||
//hasExited.acquire();
|
//hasExited.acquire();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1421,11 +1425,13 @@ class ZimResourceRequest: public Dictionary::DataRequest
|
||||||
|
|
||||||
QAtomicInt isCancelled;
|
QAtomicInt isCancelled;
|
||||||
QSemaphore hasExited;
|
QSemaphore hasExited;
|
||||||
|
QFuture< void > f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ZimResourceRequest(ZimDictionary &dict_, string const &resourceName_)
|
ZimResourceRequest(ZimDictionary &dict_, string const &resourceName_)
|
||||||
: dict(dict_), resourceName(resourceName_) {
|
: dict(dict_), resourceName(resourceName_) {
|
||||||
QThreadPool::globalInstance()->start( [ this ]() { this->run(); } );
|
f = QtConcurrent::run( [ this ]() { this->run(); } );
|
||||||
|
// QThreadPool::globalInstance()->start( [ this ]() { this->run(); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
@ -1438,6 +1444,7 @@ public:
|
||||||
~ZimResourceRequest()
|
~ZimResourceRequest()
|
||||||
{
|
{
|
||||||
isCancelled.ref();
|
isCancelled.ref();
|
||||||
|
f.waitForFinished();
|
||||||
//hasExited.acquire();
|
//hasExited.acquire();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue