##// END OF EJS Templates
Ajout de la méthode wait pour éviter de détruire un thread en cours...
perrinel -
r22:ac81b58d0bc3
parent child
Show More
@@ -9,39 +9,37 class DataSourceController::DataSourceControllerPrivate {
9 public:
9 public:
10 DataSourceControllerPrivate() {}
10 DataSourceControllerPrivate() {}
11
11
12
13 QMutex m_WorkingMutex;
12 QMutex m_WorkingMutex;
14 };
13 };
15
14
16 DataSourceController::DataSourceController(QObject *parent)
15 DataSourceController::DataSourceController(QObject *parent)
17 : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()}
16 : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()}
18 {
17 {
19 qCInfo(LOG_DataSourceController()) << tr("Construction du DataSourceController");
18 qCDebug(LOG_DataSourceController()) << tr("Construction du DataSourceController")
19 << QThread::currentThread();
20 }
20 }
21
21
22 DataSourceController::~DataSourceController()
22 DataSourceController::~DataSourceController()
23 {
23 {
24 // delete impl;
24 qCDebug(LOG_DataSourceController()) << tr("Desctruction du DataSourceController")
25 << QThread::currentThread();
25 this->waitForFinish();
26 this->waitForFinish();
26 }
27 }
27
28
28 void DataSourceController::initialize()
29 void DataSourceController::initialize()
29 {
30 {
30 qCInfo(LOG_DataSourceController()) << tr("initialize du DataSourceController");
31 qCDebug(LOG_DataSourceController()) << tr("initialize du DataSourceController")
32 << QThread::currentThread();
31 impl->m_WorkingMutex.lock();
33 impl->m_WorkingMutex.lock();
32 qCInfo(LOG_DataSourceController()) << tr("initialize du DataSourceController END");
34 qCDebug(LOG_DataSourceController()) << tr("initialize du DataSourceController END");
33 }
35 }
34
36
35 void DataSourceController::finalize()
37 void DataSourceController::finalize()
36 {
38 {
37 qCInfo(LOG_DataSourceController()) << tr("finalize du DataSourceController");
38 impl->m_WorkingMutex.unlock();
39 impl->m_WorkingMutex.unlock();
39 qCInfo(LOG_DataSourceController()) << tr("finalize du DataSourceController END");
40 }
40 }
41
41
42 void DataSourceController::waitForFinish()
42 void DataSourceController::waitForFinish()
43 {
43 {
44 qCInfo(LOG_DataSourceController()) << tr("waitForFinish du DataSourceController");
45 QMutexLocker locker(&impl->m_WorkingMutex);
44 QMutexLocker locker(&impl->m_WorkingMutex);
46 qCInfo(LOG_DataSourceController()) << tr("waitForFinish du DataSourceController END");
47 }
45 }
@@ -8,6 +8,13 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
8 class SqpApplication::SqpApplicationPrivate {
8 class SqpApplication::SqpApplicationPrivate {
9 public:
9 public:
10 SqpApplicationPrivate() {}
10 SqpApplicationPrivate() {}
11 ~SqpApplicationPrivate()
12 {
13 qCInfo(LOG_SqpApplication()) << tr("Desctruction du SqpApplicationPrivate");
14 ;
15 m_DataSourceControllerThread.quit();
16 m_DataSourceControllerThread.wait();
17 }
11
18
12 std::unique_ptr<DataSourceController> m_DataSourceController;
19 std::unique_ptr<DataSourceController> m_DataSourceController;
13 QThread m_DataSourceControllerThread;
20 QThread m_DataSourceControllerThread;
@@ -32,7 +39,6 SqpApplication::SqpApplication(int &argc, char **argv)
32
39
33 SqpApplication::~SqpApplication()
40 SqpApplication::~SqpApplication()
34 {
41 {
35 impl->m_DataSourceControllerThread.quit();
36 }
42 }
37
43
38 void SqpApplication::initialize()
44 void SqpApplication::initialize()
General Comments 0
You need to be logged in to leave comments. Login now