mirror of
https://github.com/tnodir/fort
synced 2024-11-15 10:45:10 +00:00
UI: IocContainer: Only services are auto-deletable.
This commit is contained in:
parent
49396ce920
commit
5a01c9bd79
@ -179,9 +179,9 @@ void FortManager::createManagers()
|
|||||||
ioc->setService<TaskManager>(taskManager);
|
ioc->setService<TaskManager>(taskManager);
|
||||||
|
|
||||||
ioc->setService(new AppInfoCache());
|
ioc->setService(new AppInfoCache());
|
||||||
ioc->set(new HostInfoCache());
|
ioc->setService(new HostInfoCache());
|
||||||
|
|
||||||
ioc->set(new NativeEventFilter());
|
ioc->setService(new NativeEventFilter());
|
||||||
ioc->setService(new HotKeyManager());
|
ioc->setService(new HotKeyManager());
|
||||||
|
|
||||||
if (!settings->isService()) {
|
if (!settings->isService()) {
|
||||||
|
@ -18,6 +18,8 @@ IocContainer::IocContainer(QObject *parent) : QObject(parent) { }
|
|||||||
|
|
||||||
IocContainer::~IocContainer()
|
IocContainer::~IocContainer()
|
||||||
{
|
{
|
||||||
|
autoDeleteAll();
|
||||||
|
|
||||||
if (g_tlsIndex != -1) {
|
if (g_tlsIndex != -1) {
|
||||||
TlsFree(g_tlsIndex);
|
TlsFree(g_tlsIndex);
|
||||||
g_tlsIndex = -1;
|
g_tlsIndex = -1;
|
||||||
|
@ -23,21 +23,21 @@ public:
|
|||||||
const int size() const { return m_size; }
|
const int size() const { return m_size; }
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void set(T *obj, quint8 flags = AutoDelete)
|
void set(T *obj)
|
||||||
{
|
{
|
||||||
setObject(getTypeId<T>(), obj, flags);
|
setObject(getTypeId<T>(), obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void set(T &obj)
|
void set(T &obj)
|
||||||
{
|
{
|
||||||
set(&obj, 0);
|
set(&obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void remove()
|
void remove()
|
||||||
{
|
{
|
||||||
set<T>(nullptr, 0);
|
set<T>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -55,27 +55,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T *object() const
|
inline constexpr std::enable_if_t<!std::is_base_of_v<IocService, T>, T *> resolve() const
|
||||||
{
|
{
|
||||||
return static_cast<T *>(resolveObject(getTypeId<T>()));
|
return static_cast<T *>(resolveObject(getTypeId<T>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
|
||||||
T *service() const
|
|
||||||
{
|
|
||||||
return static_cast<T *>(resolveService(getTypeId<T>()));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline constexpr std::enable_if_t<!std::is_base_of_v<IocService, T>, T *> resolve() const
|
|
||||||
{
|
|
||||||
return object<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline constexpr std::enable_if_t<std::is_base_of_v<IocService, T>, T *> resolve() const
|
inline constexpr std::enable_if_t<std::is_base_of_v<IocService, T>, T *> resolve() const
|
||||||
{
|
{
|
||||||
return service<T>();
|
return static_cast<T *>(resolveService(getTypeId<T>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUpAll();
|
void setUpAll();
|
||||||
@ -86,7 +74,7 @@ public:
|
|||||||
T *setUpDependency()
|
T *setUpDependency()
|
||||||
{
|
{
|
||||||
setUp(getTypeId<T>());
|
setUp(getTypeId<T>());
|
||||||
return service<T>();
|
return resolve<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pinToThread();
|
bool pinToThread();
|
||||||
|
@ -6,8 +6,9 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "classhelpers.h"
|
#include "classhelpers.h"
|
||||||
|
#include "ioc/iocservice.h"
|
||||||
|
|
||||||
class NativeEventFilter : public QObject, public QAbstractNativeEventFilter
|
class NativeEventFilter : public QObject, public QAbstractNativeEventFilter, public IocService
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -5,11 +5,12 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "../triggertimer.h"
|
#include "../triggertimer.h"
|
||||||
|
#include "../util/ioc/iocservice.h"
|
||||||
#include "hostinfo.h"
|
#include "hostinfo.h"
|
||||||
|
|
||||||
class HostInfoManager;
|
class HostInfoManager;
|
||||||
|
|
||||||
class HostInfoCache : public QObject
|
class HostInfoCache : public QObject, public IocService
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user