Commit a6fb9016 authored by hjk's avatar hjk

Utils: Fix lifetime of Aggregate lockers

The QReadLocker died before locking anything.

Change-Id: I8d50082bfcdd70c2e29cf637a6cfb327f106f2c3
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 14419e3d
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
void remove(QObject *component); void remove(QObject *component);
template <typename T> T *component() { template <typename T> T *component() {
QReadLocker(&lock()); QReadLocker locker(&lock());
foreach (QObject *component, m_components) { foreach (QObject *component, m_components) {
if (T *result = qobject_cast<T *>(component)) if (T *result = qobject_cast<T *>(component))
return result; return result;
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
} }
template <typename T> QList<T *> components() { template <typename T> QList<T *> components() {
QReadLocker(&lock()); QReadLocker locker(&lock());
QList<T *> results; QList<T *> results;
foreach (QObject *component, m_components) { foreach (QObject *component, m_components) {
if (T *result = qobject_cast<T *>(component)) { if (T *result = qobject_cast<T *>(component)) {
...@@ -101,7 +101,7 @@ template <typename T> T *query(QObject *obj) ...@@ -101,7 +101,7 @@ template <typename T> T *query(QObject *obj)
return (T *)0; return (T *)0;
T *result = qobject_cast<T *>(obj); T *result = qobject_cast<T *>(obj);
if (!result) { if (!result) {
QReadLocker(&lock()); QReadLocker locker(&Aggregate::lock());
Aggregate *parentAggregation = Aggregate::parentAggregate(obj); Aggregate *parentAggregation = Aggregate::parentAggregate(obj);
result = (parentAggregation ? query<T>(parentAggregation) : 0); result = (parentAggregation ? query<T>(parentAggregation) : 0);
} }
...@@ -120,7 +120,7 @@ template <typename T> QList<T *> query_all(QObject *obj) ...@@ -120,7 +120,7 @@ template <typename T> QList<T *> query_all(QObject *obj)
{ {
if (!obj) if (!obj)
return QList<T *>(); return QList<T *>();
QReadLocker(&lock()); QReadLocker locker(&Aggregate::lock());
Aggregate *parentAggregation = Aggregate::parentAggregate(obj); Aggregate *parentAggregation = Aggregate::parentAggregate(obj);
QList<T *> results; QList<T *> results;
if (parentAggregation) if (parentAggregation)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment