Browse Source
fix registry creation lock and missing init
pull/2/head
Skycoder42
7 years ago
No known key found for this signature in database
GPG Key ID: 8E01AD9EF0578D2B
2 changed files with
9 additions and
8 deletions
-
src/mvvmcore/serviceregistry.cpp
-
src/mvvmcore/serviceregistry_p.h
|
@ -131,6 +131,13 @@ void ServiceRegistryPrivate::injectLocked(QObject *object) |
|
|
tProp.write(object, variant); |
|
|
tProp.write(object, variant); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// if available, call qtmvvm_init
|
|
|
|
|
|
auto initMethod = metaObject->indexOfMethod("qtmvvm_init()"); |
|
|
|
|
|
if(initMethod != -1) { |
|
|
|
|
|
auto method = metaObject->method(initMethod); |
|
|
|
|
|
method.invoke(object); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -199,13 +206,7 @@ ServiceRegistryPrivate::MetaServiceInfo::MetaServiceInfo(const QMetaObject *meta |
|
|
|
|
|
|
|
|
QObject *ServiceRegistryPrivate::MetaServiceInfo::construct(ServiceRegistryPrivate *d) const |
|
|
QObject *ServiceRegistryPrivate::MetaServiceInfo::construct(ServiceRegistryPrivate *d) const |
|
|
{ |
|
|
{ |
|
|
auto instance = d->constructInjectedLocked(metaObject, nullptr); //services are created without a parent
|
|
|
return d->constructInjectedLocked(metaObject, nullptr); //services are created without a parent
|
|
|
auto initMethod = metaObject->indexOfMethod("qtmvvm_init()"); |
|
|
|
|
|
if(initMethod != -1) { |
|
|
|
|
|
auto method = metaObject->method(initMethod); |
|
|
|
|
|
method.invoke(instance); |
|
|
|
|
|
} |
|
|
|
|
|
return instance; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ------------- Exceptions Implementation -------------
|
|
|
// ------------- Exceptions Implementation -------------
|
|
|
|
@ -52,7 +52,7 @@ public: |
|
|
const QMetaObject *metaObject; |
|
|
const QMetaObject *metaObject; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
QMutex serviceMutex; |
|
|
QMutex serviceMutex{QMutex::Recursive}; |
|
|
QHash<QByteArray, QSharedPointer<ServiceInfo>> services; |
|
|
QHash<QByteArray, QSharedPointer<ServiceInfo>> services; |
|
|
|
|
|
|
|
|
bool serviceBlocked(const QByteArray &iid) const; |
|
|
bool serviceBlocked(const QByteArray &iid) const; |
|
|