From 5ad3c2260734ade37d2657c4bb288e3691045885 2017-12-20 13:21:03 From: Thibaud Rabillard Date: 2017-12-20 13:21:03 Subject: [PATCH] unthread the catalogue controller --- diff --git a/app/src/Main.cpp b/app/src/Main.cpp index bd42c5e..8cc71ae 100644 --- a/app/src/Main.cpp +++ b/app/src/Main.cpp @@ -49,10 +49,12 @@ int main(int argc, char *argv[]) #endif Q_INIT_RESOURCE(sqpguiresources); - SqpApplication a{argc, argv}; SqpApplication::setOrganizationName("LPP"); SqpApplication::setOrganizationDomain("lpp.fr"); SqpApplication::setApplicationName("SciQLop"); + + SqpApplication a{argc, argv}; + MainWindow w; w.show(); diff --git a/core/include/Catalogue/CatalogueController.h b/core/include/Catalogue/CatalogueController.h index de8c463..3ac6945 100644 --- a/core/include/Catalogue/CatalogueController.h +++ b/core/include/Catalogue/CatalogueController.h @@ -71,11 +71,8 @@ public: public slots: /// Manage init/end of the controller void initialize(); - void finalize(); private: - void waitForFinish(); - class CatalogueControllerPrivate; spimpl::unique_impl_ptr impl; }; diff --git a/core/src/Catalogue/CatalogueController.cpp b/core/src/Catalogue/CatalogueController.cpp index 38bc38d..cc47646 100644 --- a/core/src/Catalogue/CatalogueController.cpp +++ b/core/src/Catalogue/CatalogueController.cpp @@ -32,7 +32,6 @@ class CatalogueController::CatalogueControllerPrivate { public: explicit CatalogueControllerPrivate(CatalogueController *parent) : m_Q{parent} {} - QMutex m_WorkingMutex; CatalogueDao m_CatalogueDao; QStringList m_RepositoryList; @@ -58,7 +57,6 @@ CatalogueController::~CatalogueController() { qCDebug(LOG_CatalogueController()) << tr("CatalogueController destruction") << QThread::currentThread(); - this->waitForFinish(); } QStringList CatalogueController::getRepositories() const @@ -279,9 +277,14 @@ CatalogueController::eventsForMimeData(const QByteArray &mimeData) const void CatalogueController::initialize() { +<<<<<<< HEAD qCDebug(LOG_CatalogueController()) << tr("CatalogueController init") << QThread::currentThread(); impl->m_WorkingMutex.lock(); +======= + qCDebug(LOG_CatalogueController()) + << tr("CatalogueController init") << QThread::currentThread(); +>>>>>>> 286decc... unthread the catalogue controller impl->m_CatalogueDao.initialize(); auto defaultRepositoryLocation = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); @@ -303,16 +306,6 @@ void CatalogueController::initialize() qCDebug(LOG_CatalogueController()) << tr("CatalogueController init END"); } -void CatalogueController::finalize() -{ - impl->m_WorkingMutex.unlock(); -} - -void CatalogueController::waitForFinish() -{ - QMutexLocker locker{&impl->m_WorkingMutex}; -} - void CatalogueController::CatalogueControllerPrivate::copyDBtoDB(const QString &dbFrom, const QString &dbTo) { diff --git a/gui/src/SqpApplication.cpp b/gui/src/SqpApplication.cpp index d5dc264..b69af14 100644 --- a/gui/src/SqpApplication.cpp +++ b/gui/src/SqpApplication.cpp @@ -64,9 +64,6 @@ public: m_VariableControllerThread.setObjectName("VariableControllerThread"); m_VisualizationController->moveToThread(&m_VisualizationControllerThread); m_VisualizationControllerThread.setObjectName("VsualizationControllerThread"); - m_CatalogueController->moveToThread(&m_CatalogueControllerThread); - m_CatalogueControllerThread.setObjectName("CatalogueControllerThread"); - // Additionnal init m_VariableController->setTimeController(m_TimeController.get()); @@ -85,9 +82,6 @@ public: m_VisualizationControllerThread.quit(); m_VisualizationControllerThread.wait(); - - m_CatalogueControllerThread.quit(); - m_CatalogueControllerThread.wait(); } std::unique_ptr m_DataSourceController; @@ -101,7 +95,6 @@ public: QThread m_NetworkControllerThread; QThread m_VariableControllerThread; QThread m_VisualizationControllerThread; - QThread m_CatalogueControllerThread; std::unique_ptr m_DragDropGuiController; std::unique_ptr m_ActionsGuiController; @@ -136,16 +129,11 @@ SqpApplication::SqpApplication(int &argc, char **argv) connect(&impl->m_VisualizationControllerThread, &QThread::finished, impl->m_VisualizationController.get(), &VisualizationController::finalize); - connect(&impl->m_CatalogueControllerThread, &QThread::started, - impl->m_CatalogueController.get(), &CatalogueController::initialize); - connect(&impl->m_CatalogueControllerThread, &QThread::finished, - impl->m_CatalogueController.get(), &CatalogueController::finalize); - impl->m_DataSourceControllerThread.start(); impl->m_NetworkControllerThread.start(); impl->m_VariableControllerThread.start(); impl->m_VisualizationControllerThread.start(); - impl->m_CatalogueControllerThread.start(); + impl->m_CatalogueController->initialize(); } SqpApplication::~SqpApplication()