From 00c165d3a5e1ef5b79c95d54e6edb8421e1ae7c9 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 28 May 2015 08:44:17 +1000 Subject: [PATCH 1/6] Add user preference option to check unused or redundant pathgrid points. Also resolve namespace clash issue in osx. --- apps/opencs/model/settings/usersettings.cpp | 7 ++++++ apps/opencs/model/tools/pathgridcheck.cpp | 24 ++++++++++++--------- apps/opencs/model/tools/pathgridcheck.hpp | 14 ++++++++++-- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index ea002c5ed..ea75fd6d9 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -264,6 +264,13 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() monoFont->setToolTip ("Whether to use monospaced fonts on script edit subview."); } + declareSection ("verifier", "Verifier"); + { + Setting *extraPathgrid = createSetting (Type_CheckBox, "pathgrid-extra-check", "Pathgrid: Extra Check"); + extraPathgrid->setDefaultValue ("false"); + extraPathgrid->setToolTip ("Additional checks for orphaned or duplicated pathgrid points"); + } + { /****************************************************************** * There are three types of values: diff --git a/apps/opencs/model/tools/pathgridcheck.cpp b/apps/opencs/model/tools/pathgridcheck.cpp index 8f22cc8cd..c436cfe04 100644 --- a/apps/opencs/model/tools/pathgridcheck.cpp +++ b/apps/opencs/model/tools/pathgridcheck.cpp @@ -8,15 +8,7 @@ #include "../world/subcellcollection.hpp" #include "../world/pathgrid.hpp" -namespace -{ - struct Point - { - unsigned char mConnectionNum; - std::vector mOtherIndex; - Point() : mConnectionNum(0), mOtherIndex(0) {} - }; -} +#include "../settings/usersettings.hpp" CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection& pathgrids) : mPathgrids (pathgrids) @@ -29,6 +21,12 @@ int CSMTools::PathgridCheckStage::setup() void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& messages) { + // NOTE: This is horribly inefficient but in order to use signals the entire Stage class + // hierarchy needs to be braught under Qt which seems like an overkill for a small + // performance gain during verify operations + CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); + bool extraCheck = userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true"; + const CSMWorld::Record& record = mPathgrids.getRecord (stage); if (record.isDeleted()) @@ -44,7 +42,7 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message else if (pathgrid.mData.mS2 > static_cast(pathgrid.mPoints.size())) messages.push_back (std::make_pair (id, pathgrid.mId + " has more points than expected")); - std::vector pointList(pathgrid.mPoints.size()); + std::vector pointList(pathgrid.mPoints.size()); std::vector duplList; for (unsigned int i = 0; i < pathgrid.mEdges.size(); ++i) @@ -115,6 +113,9 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message } } + if (!extraCheck) + continue; + // check duplicate points // FIXME: how to do this efficiently? for (unsigned int j = 0; j < pathgrid.mPoints.size(); ++j) @@ -143,6 +144,9 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message } } + if (!extraCheck) + return; + // check pathgrid points that are not connected to anything for (unsigned int i = 0; i < pointList.size(); ++i) { diff --git a/apps/opencs/model/tools/pathgridcheck.hpp b/apps/opencs/model/tools/pathgridcheck.hpp index c90dbc8ed..603235552 100644 --- a/apps/opencs/model/tools/pathgridcheck.hpp +++ b/apps/opencs/model/tools/pathgridcheck.hpp @@ -14,13 +14,23 @@ namespace CSMWorld namespace CSMTools { + + struct Point + { + unsigned char mConnectionNum; + std::vector mOtherIndex; + Point() : mConnectionNum(0), mOtherIndex(0) {} + }; + class PathgridCheckStage : public CSMDoc::Stage { - const CSMWorld::SubCellCollection >& mPathgrids; + const CSMWorld::SubCellCollection >& mPathgrids; public: - PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids); + PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids); virtual int setup(); From 734e52d1c82e2f2a250c3a11fbaecd53592ee27f Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 29 May 2015 06:40:40 +1000 Subject: [PATCH 2/6] Move the user preference check to the preparation step before the running of the operation. --- apps/opencs/model/tools/pathgridcheck.cpp | 13 +++++-------- apps/opencs/model/tools/pathgridcheck.hpp | 15 ++++++++------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/apps/opencs/model/tools/pathgridcheck.cpp b/apps/opencs/model/tools/pathgridcheck.cpp index c436cfe04..58fdbeb2d 100644 --- a/apps/opencs/model/tools/pathgridcheck.cpp +++ b/apps/opencs/model/tools/pathgridcheck.cpp @@ -16,17 +16,14 @@ CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollect int CSMTools::PathgridCheckStage::setup() { + CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); + mExtraCheck = userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true"; + return mPathgrids.getSize(); } void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& messages) { - // NOTE: This is horribly inefficient but in order to use signals the entire Stage class - // hierarchy needs to be braught under Qt which seems like an overkill for a small - // performance gain during verify operations - CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - bool extraCheck = userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true"; - const CSMWorld::Record& record = mPathgrids.getRecord (stage); if (record.isDeleted()) @@ -113,7 +110,7 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message } } - if (!extraCheck) + if (!mExtraCheck) continue; // check duplicate points @@ -144,7 +141,7 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message } } - if (!extraCheck) + if (!mExtraCheck) return; // check pathgrid points that are not connected to anything diff --git a/apps/opencs/model/tools/pathgridcheck.hpp b/apps/opencs/model/tools/pathgridcheck.hpp index 603235552..86ace6af2 100644 --- a/apps/opencs/model/tools/pathgridcheck.hpp +++ b/apps/opencs/model/tools/pathgridcheck.hpp @@ -24,17 +24,18 @@ namespace CSMTools class PathgridCheckStage : public CSMDoc::Stage { - const CSMWorld::SubCellCollection >& mPathgrids; + bool mExtraCheck; + const CSMWorld::SubCellCollection >& mPathgrids; - public: + public: - PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids); + PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids); - virtual int setup(); + virtual int setup(); - virtual void perform (int stage, CSMDoc::Messages& messages); + virtual void perform (int stage, CSMDoc::Messages& messages); }; } From 393cee406fce7f0781c55451b53efd06427d2ab7 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 29 May 2015 19:28:25 +1000 Subject: [PATCH 3/6] Use signals for user preference setting updates. --- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/model/tools/pathgridcheck.cpp | 15 +++++++++---- apps/opencs/model/tools/pathgridcheck.hpp | 7 +++++- apps/opencs/model/tools/signalhandler.cpp | 23 ++++++++++++++++++++ apps/opencs/model/tools/signalhandler.hpp | 26 +++++++++++++++++++++++ apps/opencs/model/tools/tools.cpp | 9 ++++++-- apps/opencs/model/tools/tools.hpp | 2 +- 7 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 apps/opencs/model/tools/signalhandler.cpp create mode 100644 apps/opencs/model/tools/signalhandler.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 78b2deb7a..9ed0d6a8b 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -34,7 +34,7 @@ opencs_hdrs_noqt (model/world opencs_units (model/tools - tools reportmodel + tools reportmodel signalhandler ) opencs_units_noqt (model/tools diff --git a/apps/opencs/model/tools/pathgridcheck.cpp b/apps/opencs/model/tools/pathgridcheck.cpp index 58fdbeb2d..2b11b7066 100644 --- a/apps/opencs/model/tools/pathgridcheck.cpp +++ b/apps/opencs/model/tools/pathgridcheck.cpp @@ -10,14 +10,21 @@ #include "../settings/usersettings.hpp" -CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection& pathgrids) -: mPathgrids (pathgrids) +#include "signalhandler.hpp" + +CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection& pathgrids, + CSMTools::SignalHandler *signalHandler) +: mPathgrids (pathgrids), mSigHandler(signalHandler) {} +CSMTools::PathgridCheckStage::~PathgridCheckStage () +{ + delete mSigHandler; +} + int CSMTools::PathgridCheckStage::setup() { - CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - mExtraCheck = userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true"; + mExtraCheck = mSigHandler->extraCheck(); return mPathgrids.getSize(); } diff --git a/apps/opencs/model/tools/pathgridcheck.hpp b/apps/opencs/model/tools/pathgridcheck.hpp index 86ace6af2..8b5dc08a7 100644 --- a/apps/opencs/model/tools/pathgridcheck.hpp +++ b/apps/opencs/model/tools/pathgridcheck.hpp @@ -14,6 +14,7 @@ namespace CSMWorld namespace CSMTools { + class SignalHandler; struct Point { @@ -25,13 +26,17 @@ namespace CSMTools class PathgridCheckStage : public CSMDoc::Stage { bool mExtraCheck; + CSMTools::SignalHandler *mSigHandler; + const CSMWorld::SubCellCollection >& mPathgrids; public: PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids); + CSMWorld::IdAccessor >& pathgrids, CSMTools::SignalHandler *signallHandler); + + ~PathgridCheckStage (); virtual int setup(); diff --git a/apps/opencs/model/tools/signalhandler.cpp b/apps/opencs/model/tools/signalhandler.cpp new file mode 100644 index 000000000..cfb52ed63 --- /dev/null +++ b/apps/opencs/model/tools/signalhandler.cpp @@ -0,0 +1,23 @@ +#include "signalhandler.hpp" + +#include "../settings/usersettings.hpp" + +CSMTools::SignalHandler::SignalHandler(bool extraCheck) + : mExtraCheck(extraCheck) +{ + connect (&CSMSettings::UserSettings::instance(), + SIGNAL (userSettingUpdated(const QString &, const QStringList &)), + this, + SLOT (updateUserSetting (const QString &, const QStringList &))); +} + +void CSMTools::SignalHandler::updateUserSetting (const QString &name, const QStringList &list) +{ + if (name=="verifier/pathgrid-extra-check") + mExtraCheck = list.at(0) == "true"; +} + +bool CSMTools::SignalHandler::extraCheck () +{ + return mExtraCheck; +} diff --git a/apps/opencs/model/tools/signalhandler.hpp b/apps/opencs/model/tools/signalhandler.hpp new file mode 100644 index 000000000..c3d075fdf --- /dev/null +++ b/apps/opencs/model/tools/signalhandler.hpp @@ -0,0 +1,26 @@ +#ifndef CSM_TOOLS_SIGNALHANDLER_H +#define CSM_TOOLS_SIGNALHANDLER_H + +#include + +namespace CSMTools +{ + class SignalHandler : public QObject + { + Q_OBJECT + + bool mExtraCheck; + + public: + + SignalHandler (bool extraCheck); + + bool extraCheck (); + + public slots: + + void updateUserSetting (const QString &name, const QStringList &list); + }; +} + +#endif diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 8d93a9433..45c7fbae3 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -10,6 +10,8 @@ #include "../world/data.hpp" #include "../world/universalid.hpp" +#include "../settings/usersettings.hpp" + #include "reportmodel.hpp" #include "mandatoryid.hpp" #include "skillcheck.hpp" @@ -27,6 +29,7 @@ #include "startscriptcheck.hpp" #include "searchoperation.hpp" #include "pathgridcheck.hpp" +#include "signalhandler.hpp" CSMDoc::OperationHolder *CSMTools::Tools::get (int type) { @@ -56,6 +59,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier() SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)), this, SLOT (verifierMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int))); + CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); + std::vector mandatoryIds; // I want C++11, damn it! mandatoryIds.push_back ("Day"); mandatoryIds.push_back ("DaysPassed"); @@ -97,7 +102,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier() CSMWorld::UniversalId( CSMWorld::UniversalId::Type_Meshes )), mData.getRaces() )); - mVerifierOperation->appendStage (new PathgridCheckStage (mData.getPathgrids())); + mVerifierOperation->appendStage (new PathgridCheckStage (mData.getPathgrids(), + new SignalHandler(userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true"))); mVerifier.setOperation (mVerifierOperation); } @@ -213,4 +219,3 @@ void CSMTools::Tools::verifierMessage (const CSMWorld::UniversalId& id, const st if (iter!=mActiveReports.end()) mReports[iter->second]->add (id, message, hint); } - diff --git a/apps/opencs/model/tools/tools.hpp b/apps/opencs/model/tools/tools.hpp index 0f9e57044..dc19cf456 100644 --- a/apps/opencs/model/tools/tools.hpp +++ b/apps/opencs/model/tools/tools.hpp @@ -64,7 +64,7 @@ namespace CSMTools CSMWorld::UniversalId newSearch(); void runSearch (const CSMWorld::UniversalId& searchId, const Search& search); - + void abortOperation (int type); ///< \attention The operation is not aborted immediately. From 76196d815dcd4172b16a751352a52b056b5ab58b Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 30 May 2015 18:58:33 +1000 Subject: [PATCH 4/6] Update user preference setting value via an event message queue. --- apps/opencs/model/tools/signalhandler.cpp | 14 ++++++++++++-- apps/opencs/model/tools/signalhandler.hpp | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/tools/signalhandler.cpp b/apps/opencs/model/tools/signalhandler.cpp index cfb52ed63..64e5ead55 100644 --- a/apps/opencs/model/tools/signalhandler.cpp +++ b/apps/opencs/model/tools/signalhandler.cpp @@ -1,5 +1,7 @@ #include "signalhandler.hpp" +#include + #include "../settings/usersettings.hpp" CSMTools::SignalHandler::SignalHandler(bool extraCheck) @@ -11,12 +13,20 @@ CSMTools::SignalHandler::SignalHandler(bool extraCheck) SLOT (updateUserSetting (const QString &, const QStringList &))); } +// called from the main thread void CSMTools::SignalHandler::updateUserSetting (const QString &name, const QStringList &list) { - if (name=="verifier/pathgrid-extra-check") - mExtraCheck = list.at(0) == "true"; + if (name=="verifier/pathgrid-extra-check" && !list.empty()) + QMetaObject::invokeMethod(this, "updateExtraCheck", Qt::AutoConnection, Q_ARG(bool, list.at(0) == "true")); +} + +// should be in the operations thread via an event message queue +void CSMTools::SignalHandler::updateExtraCheck (bool extraCheck) +{ + mExtraCheck = extraCheck; } +// called from the operations thread bool CSMTools::SignalHandler::extraCheck () { return mExtraCheck; diff --git a/apps/opencs/model/tools/signalhandler.hpp b/apps/opencs/model/tools/signalhandler.hpp index c3d075fdf..bc063ebd6 100644 --- a/apps/opencs/model/tools/signalhandler.hpp +++ b/apps/opencs/model/tools/signalhandler.hpp @@ -20,6 +20,10 @@ namespace CSMTools public slots: void updateUserSetting (const QString &name, const QStringList &list); + + private slots: + + void updateExtraCheck (bool extraCheck); }; } From 01eba7b721be21a71f54431721b0da039d7c1074 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 30 May 2015 19:17:42 +1000 Subject: [PATCH 5/6] Extra check for thread affinity. --- apps/opencs/model/tools/signalhandler.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/opencs/model/tools/signalhandler.cpp b/apps/opencs/model/tools/signalhandler.cpp index 64e5ead55..2e94e1f87 100644 --- a/apps/opencs/model/tools/signalhandler.cpp +++ b/apps/opencs/model/tools/signalhandler.cpp @@ -1,6 +1,7 @@ #include "signalhandler.hpp" #include +#include #include "../settings/usersettings.hpp" @@ -23,6 +24,13 @@ void CSMTools::SignalHandler::updateUserSetting (const QString &name, const QStr // should be in the operations thread via an event message queue void CSMTools::SignalHandler::updateExtraCheck (bool extraCheck) { + if (thread()!=QThread::currentThread()) + { + QMetaObject::invokeMethod(this,"updateExtraCheck", Qt::QueuedConnection, Q_ARG(bool, extraCheck)); + return; + } + + // extra safety mExtraCheck = extraCheck; } From c4aa3d3ee319a884e77f05313f3a4441cd6f98dc Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 30 May 2015 21:12:47 +1000 Subject: [PATCH 6/6] Revert user preference setting checks until a thread safe method is worked out. The OSX namespace issue is retained. --- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/model/settings/usersettings.cpp | 7 ---- apps/opencs/model/tools/pathgridcheck.cpp | 22 +---------- apps/opencs/model/tools/pathgridcheck.hpp | 9 +---- apps/opencs/model/tools/signalhandler.cpp | 41 --------------------- apps/opencs/model/tools/signalhandler.hpp | 30 --------------- apps/opencs/model/tools/tools.cpp | 9 +---- apps/opencs/model/tools/tools.hpp | 2 +- 8 files changed, 7 insertions(+), 115 deletions(-) delete mode 100644 apps/opencs/model/tools/signalhandler.cpp delete mode 100644 apps/opencs/model/tools/signalhandler.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 9ed0d6a8b..78b2deb7a 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -34,7 +34,7 @@ opencs_hdrs_noqt (model/world opencs_units (model/tools - tools reportmodel signalhandler + tools reportmodel ) opencs_units_noqt (model/tools diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index ea75fd6d9..ea002c5ed 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -264,13 +264,6 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() monoFont->setToolTip ("Whether to use monospaced fonts on script edit subview."); } - declareSection ("verifier", "Verifier"); - { - Setting *extraPathgrid = createSetting (Type_CheckBox, "pathgrid-extra-check", "Pathgrid: Extra Check"); - extraPathgrid->setDefaultValue ("false"); - extraPathgrid->setToolTip ("Additional checks for orphaned or duplicated pathgrid points"); - } - { /****************************************************************** * There are three types of values: diff --git a/apps/opencs/model/tools/pathgridcheck.cpp b/apps/opencs/model/tools/pathgridcheck.cpp index 2b11b7066..76edeb573 100644 --- a/apps/opencs/model/tools/pathgridcheck.cpp +++ b/apps/opencs/model/tools/pathgridcheck.cpp @@ -8,24 +8,12 @@ #include "../world/subcellcollection.hpp" #include "../world/pathgrid.hpp" -#include "../settings/usersettings.hpp" - -#include "signalhandler.hpp" - -CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection& pathgrids, - CSMTools::SignalHandler *signalHandler) -: mPathgrids (pathgrids), mSigHandler(signalHandler) +CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection& pathgrids) +: mPathgrids (pathgrids) {} -CSMTools::PathgridCheckStage::~PathgridCheckStage () -{ - delete mSigHandler; -} - int CSMTools::PathgridCheckStage::setup() { - mExtraCheck = mSigHandler->extraCheck(); - return mPathgrids.getSize(); } @@ -117,9 +105,6 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message } } - if (!mExtraCheck) - continue; - // check duplicate points // FIXME: how to do this efficiently? for (unsigned int j = 0; j < pathgrid.mPoints.size(); ++j) @@ -148,9 +133,6 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message } } - if (!mExtraCheck) - return; - // check pathgrid points that are not connected to anything for (unsigned int i = 0; i < pointList.size(); ++i) { diff --git a/apps/opencs/model/tools/pathgridcheck.hpp b/apps/opencs/model/tools/pathgridcheck.hpp index 8b5dc08a7..f45b5bc93 100644 --- a/apps/opencs/model/tools/pathgridcheck.hpp +++ b/apps/opencs/model/tools/pathgridcheck.hpp @@ -14,8 +14,6 @@ namespace CSMWorld namespace CSMTools { - class SignalHandler; - struct Point { unsigned char mConnectionNum; @@ -25,18 +23,13 @@ namespace CSMTools class PathgridCheckStage : public CSMDoc::Stage { - bool mExtraCheck; - CSMTools::SignalHandler *mSigHandler; - const CSMWorld::SubCellCollection >& mPathgrids; public: PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids, CSMTools::SignalHandler *signallHandler); - - ~PathgridCheckStage (); + CSMWorld::IdAccessor >& pathgrids); virtual int setup(); diff --git a/apps/opencs/model/tools/signalhandler.cpp b/apps/opencs/model/tools/signalhandler.cpp deleted file mode 100644 index 2e94e1f87..000000000 --- a/apps/opencs/model/tools/signalhandler.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "signalhandler.hpp" - -#include -#include - -#include "../settings/usersettings.hpp" - -CSMTools::SignalHandler::SignalHandler(bool extraCheck) - : mExtraCheck(extraCheck) -{ - connect (&CSMSettings::UserSettings::instance(), - SIGNAL (userSettingUpdated(const QString &, const QStringList &)), - this, - SLOT (updateUserSetting (const QString &, const QStringList &))); -} - -// called from the main thread -void CSMTools::SignalHandler::updateUserSetting (const QString &name, const QStringList &list) -{ - if (name=="verifier/pathgrid-extra-check" && !list.empty()) - QMetaObject::invokeMethod(this, "updateExtraCheck", Qt::AutoConnection, Q_ARG(bool, list.at(0) == "true")); -} - -// should be in the operations thread via an event message queue -void CSMTools::SignalHandler::updateExtraCheck (bool extraCheck) -{ - if (thread()!=QThread::currentThread()) - { - QMetaObject::invokeMethod(this,"updateExtraCheck", Qt::QueuedConnection, Q_ARG(bool, extraCheck)); - return; - } - - // extra safety - mExtraCheck = extraCheck; -} - -// called from the operations thread -bool CSMTools::SignalHandler::extraCheck () -{ - return mExtraCheck; -} diff --git a/apps/opencs/model/tools/signalhandler.hpp b/apps/opencs/model/tools/signalhandler.hpp deleted file mode 100644 index bc063ebd6..000000000 --- a/apps/opencs/model/tools/signalhandler.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef CSM_TOOLS_SIGNALHANDLER_H -#define CSM_TOOLS_SIGNALHANDLER_H - -#include - -namespace CSMTools -{ - class SignalHandler : public QObject - { - Q_OBJECT - - bool mExtraCheck; - - public: - - SignalHandler (bool extraCheck); - - bool extraCheck (); - - public slots: - - void updateUserSetting (const QString &name, const QStringList &list); - - private slots: - - void updateExtraCheck (bool extraCheck); - }; -} - -#endif diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 45c7fbae3..8d93a9433 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -10,8 +10,6 @@ #include "../world/data.hpp" #include "../world/universalid.hpp" -#include "../settings/usersettings.hpp" - #include "reportmodel.hpp" #include "mandatoryid.hpp" #include "skillcheck.hpp" @@ -29,7 +27,6 @@ #include "startscriptcheck.hpp" #include "searchoperation.hpp" #include "pathgridcheck.hpp" -#include "signalhandler.hpp" CSMDoc::OperationHolder *CSMTools::Tools::get (int type) { @@ -59,8 +56,6 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier() SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int)), this, SLOT (verifierMessage (const CSMWorld::UniversalId&, const std::string&, const std::string&, int))); - CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - std::vector mandatoryIds; // I want C++11, damn it! mandatoryIds.push_back ("Day"); mandatoryIds.push_back ("DaysPassed"); @@ -102,8 +97,7 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier() CSMWorld::UniversalId( CSMWorld::UniversalId::Type_Meshes )), mData.getRaces() )); - mVerifierOperation->appendStage (new PathgridCheckStage (mData.getPathgrids(), - new SignalHandler(userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true"))); + mVerifierOperation->appendStage (new PathgridCheckStage (mData.getPathgrids())); mVerifier.setOperation (mVerifierOperation); } @@ -219,3 +213,4 @@ void CSMTools::Tools::verifierMessage (const CSMWorld::UniversalId& id, const st if (iter!=mActiveReports.end()) mReports[iter->second]->add (id, message, hint); } + diff --git a/apps/opencs/model/tools/tools.hpp b/apps/opencs/model/tools/tools.hpp index dc19cf456..0f9e57044 100644 --- a/apps/opencs/model/tools/tools.hpp +++ b/apps/opencs/model/tools/tools.hpp @@ -64,7 +64,7 @@ namespace CSMTools CSMWorld::UniversalId newSearch(); void runSearch (const CSMWorld::UniversalId& searchId, const Search& search); - + void abortOperation (int type); ///< \attention The operation is not aborted immediately.