diff --git a/src/tests/UtilTest/tst_ioccontainer.h b/src/tests/UtilTest/tst_ioccontainer.h index 3c3f18bd..9dc362f5 100644 --- a/src/tests/UtilTest/tst_ioccontainer.h +++ b/src/tests/UtilTest/tst_ioccontainer.h @@ -43,7 +43,7 @@ public: void setUp() override { IocService::setUp(); - IoC()->setUpDependency(); + IoCPinned()->setUpDependency(); } }; diff --git a/src/ui/appinfo/appinfocache.cpp b/src/ui/appinfo/appinfocache.cpp index 30e9e05a..13b7ffc7 100644 --- a/src/ui/appinfo/appinfocache.cpp +++ b/src/ui/appinfo/appinfocache.cpp @@ -15,7 +15,7 @@ AppInfoCache::AppInfoCache(QObject *parent) : QObject(parent), m_cache(1000) void AppInfoCache::setUp() { - auto appInfoManager = IoC()->setUpDependency(); + auto appInfoManager = IoCPinned()->setUpDependency(); connect(appInfoManager, &AppInfoManager::lookupInfoFinished, this, &AppInfoCache::handleFinishedInfoLookup); diff --git a/src/ui/conf/confappmanager.cpp b/src/ui/conf/confappmanager.cpp index c58085d6..a980711c 100644 --- a/src/ui/conf/confappmanager.cpp +++ b/src/ui/conf/confappmanager.cpp @@ -142,7 +142,7 @@ FirewallConf *ConfAppManager::conf() const void ConfAppManager::setUp() { - m_confManager = IoC()->setUpDependency(); + m_confManager = IoCPinned()->setUpDependency(); setupDriveListManager(); diff --git a/src/ui/conf/confzonemanager.cpp b/src/ui/conf/confzonemanager.cpp index e5412d60..3f6fde6e 100644 --- a/src/ui/conf/confzonemanager.cpp +++ b/src/ui/conf/confzonemanager.cpp @@ -98,7 +98,7 @@ SqliteDb *ConfZoneManager::sqliteDb() const void ConfZoneManager::setUp() { - m_confManager = IoC()->setUpDependency(); + m_confManager = IoCPinned()->setUpDependency(); } bool ConfZoneManager::addOrUpdateZone(Zone &zone) diff --git a/src/ui/fortmanager.cpp b/src/ui/fortmanager.cpp index 0af199dc..985f2e29 100644 --- a/src/ui/fortmanager.cpp +++ b/src/ui/fortmanager.cpp @@ -207,7 +207,7 @@ void FortManager::updateLogger(const FirewallConf *conf) void FortManager::createManagers() { - IocContainer *ioc = IoC(); + IocContainer *ioc = IoCPinned(); const auto settings = IoC(); @@ -223,7 +223,7 @@ void FortManager::createManagers() void FortManager::deleteManagers() { - IocContainer *ioc = IoC(); + IocContainer *ioc = IoCPinned(); ioc->tearDownAll(); ioc->autoDeleteAll(); diff --git a/src/ui/log/logmanager.cpp b/src/ui/log/logmanager.cpp index 40283497..7783b7f2 100644 --- a/src/ui/log/logmanager.cpp +++ b/src/ui/log/logmanager.cpp @@ -62,7 +62,7 @@ void LogManager::setCurrentUnixTime(qint64 unixTime) void LogManager::setUp() { - const auto driverManager = IoC()->setUpDependency(); + const auto driverManager = IoCPinned()->setUpDependency(); connect(driverManager->driverWorker(), &DriverWorker::readLogResult, this, &LogManager::processLogBuffer, Qt::QueuedConnection); diff --git a/src/ui/manager/hotkeymanager.cpp b/src/ui/manager/hotkeymanager.cpp index 91d3a1a3..addab1b1 100644 --- a/src/ui/manager/hotkeymanager.cpp +++ b/src/ui/manager/hotkeymanager.cpp @@ -25,7 +25,7 @@ void HotKeyManager::initialize(bool enabled, bool global) void HotKeyManager::setUp() { - auto nativeEventFilter = IoC()->setUpDependency(); + auto nativeEventFilter = IoCPinned()->setUpDependency(); connect(nativeEventFilter, &NativeEventFilter::hotKeyPressed, this, &HotKeyManager::onHotKeyPressed); diff --git a/src/ui/manager/servicemanager.cpp b/src/ui/manager/servicemanager.cpp index 8ca09ba0..bd015276 100644 --- a/src/ui/manager/servicemanager.cpp +++ b/src/ui/manager/servicemanager.cpp @@ -54,7 +54,7 @@ void ServiceManager::initialize(qintptr hstatus) void ServiceManager::setupControlManager() { - auto controlManager = IoC()->setUpDependency(); + auto controlManager = IoCPinned()->setUpDependency(); connect(this, &ServiceManager::pauseRequested, controlManager, [controlManager] { controlManager->close(); @@ -65,7 +65,7 @@ void ServiceManager::setupControlManager() void ServiceManager::setupConfManager() { - auto confManager = IoC()->setUpDependency(); + auto confManager = IoCPinned()->setUpDependency(); connect(confManager, &ConfManager::iniChanged, this, &ServiceManager::setupByConf); } diff --git a/src/ui/manager/translationmanager.cpp b/src/ui/manager/translationmanager.cpp index 11014ad1..78bde5a7 100644 --- a/src/ui/manager/translationmanager.cpp +++ b/src/ui/manager/translationmanager.cpp @@ -34,7 +34,7 @@ QString TranslationManager::languageName() const void TranslationManager::setUp() { - auto confManager = IoC()->setUpDependency(); + auto confManager = IoCPinned()->setUpDependency(); connect(confManager, &ConfManager::iniUserChanged, this, &TranslationManager::setupByIniUser); diff --git a/src/ui/manager/windowmanager.cpp b/src/ui/manager/windowmanager.cpp index a8d1ceb5..fde72a6f 100644 --- a/src/ui/manager/windowmanager.cpp +++ b/src/ui/manager/windowmanager.cpp @@ -120,7 +120,7 @@ void WindowManager::setupMainWindow() m_mainWindow->setFont(defaultFont()); // Register Native events - auto nativeEventFilter = IoC()->setUpDependency(); + auto nativeEventFilter = IoCPinned()->setUpDependency(); nativeEventFilter->registerSessionNotification(mainWindow()->winId()); @@ -220,7 +220,7 @@ void WindowManager::setupStatisticsWindow() void WindowManager::setupConfManager() { - auto confManager = IoC()->setUpDependency(); + auto confManager = IoCPinned()->setUpDependency(); connect(confManager, &ConfManager::iniUserChanged, this, &WindowManager::setupByIniUser); } diff --git a/src/ui/model/zonelistmodel.cpp b/src/ui/model/zonelistmodel.cpp index aecd19c2..4c02d3aa 100644 --- a/src/ui/model/zonelistmodel.cpp +++ b/src/ui/model/zonelistmodel.cpp @@ -39,7 +39,7 @@ SqliteDb *ZoneListModel::sqliteDb() const void ZoneListModel::setUp() { - auto confZoneManager = IoC()->setUpDependency(); + auto confZoneManager = IoCPinned()->setUpDependency(); setupZoneTypes(); setupZoneSources(); diff --git a/src/ui/rpc/rpcmanager.cpp b/src/ui/rpc/rpcmanager.cpp index 37074dd3..ad8ffaab 100644 --- a/src/ui/rpc/rpcmanager.cpp +++ b/src/ui/rpc/rpcmanager.cpp @@ -687,7 +687,7 @@ void RpcManager::setupTaskManagerSignals() void RpcManager::setupClient() { - auto controlManager = IoC()->setUpDependency(); + auto controlManager = IoCPinned()->setUpDependency(); m_client = controlManager->newServiceClient(this); diff --git a/src/ui/stat/quotamanager.cpp b/src/ui/stat/quotamanager.cpp index 449134c3..7f0ac377 100644 --- a/src/ui/stat/quotamanager.cpp +++ b/src/ui/stat/quotamanager.cpp @@ -121,7 +121,7 @@ QString QuotaManager::alertTypeText(qint8 alertType) void QuotaManager::setupConfManager() { - auto confManager = IoC()->setUpDependency(); + auto confManager = IoCPinned()->setUpDependency(); connect(confManager, &ConfManager::iniChanged, this, &QuotaManager::setupByConf); } diff --git a/src/ui/stat/statblockmanager.cpp b/src/ui/stat/statblockmanager.cpp index 79acc0e5..07ac3493 100644 --- a/src/ui/stat/statblockmanager.cpp +++ b/src/ui/stat/statblockmanager.cpp @@ -158,7 +158,7 @@ void StatBlockManager::setupWorker() void StatBlockManager::setupConfManager() { - auto confManager = IoC()->setUpDependency(); + auto confManager = IoCPinned()->setUpDependency(); connect(confManager, &ConfManager::iniChanged, this, &StatBlockManager::setupByConf); } diff --git a/src/ui/task/taskmanager.cpp b/src/ui/task/taskmanager.cpp index 6d762d7c..15fe69dc 100644 --- a/src/ui/task/taskmanager.cpp +++ b/src/ui/task/taskmanager.cpp @@ -60,7 +60,7 @@ void TaskManager::appendTaskInfo(TaskInfo *taskInfo) void TaskManager::loadSettings() { - auto confManager = IoC()->setUpDependency(); + auto confManager = IoCPinned()->setUpDependency(); confManager->loadTasks(taskInfoList()); } diff --git a/src/ui/util/ioc/ioccontainer.h b/src/ui/util/ioc/ioccontainer.h index 62687fc3..03181db1 100644 --- a/src/ui/util/ioc/ioccontainer.h +++ b/src/ui/util/ioc/ioccontainer.h @@ -119,14 +119,14 @@ private: IocObject *m_objects[IOC_MAX_SIZE] = {}; }; +constexpr auto IoCPinned = IocContainer::getPinned; + template inline static T *IoC() { - const IocContainer *container = IocContainer::getPinned(); + const IocContainer *container = IoCPinned(); Q_ASSERT(container); return container->resolve(); } -#define IoC() IocContainer::getPinned() - #endif // IOCCONTAINER_H