aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativecontext_p.h
diff options
context:
space:
mode:
authorGlenn Watson <glenn.watson@nokia.com>2011-11-22 09:13:21 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-22 03:31:11 +0100
commit0bf08af2b945f10f44561ffa0abd6f89b093b376 (patch)
treef7cb7e6cd3061eaf3878bf8787708ed03428c07e /src/declarative/qml/qdeclarativecontext_p.h
parent3ef0ce6b794ed58d26ec6355cc13fd00f66c5176 (diff)
Fix default property preventing signals from being emitted.
Change the way connectAlias works so that even if the target for the connection is not available immediately, anything that is bound to it is notified when the target is changed. (Fix is authored by Aaron). Task-number: QTBUG-21580 Change-Id: Ida23c0e620069c50b123c71b5078929d4c7ec4e4 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/declarative/qml/qdeclarativecontext_p.h')
-rw-r--r--src/declarative/qml/qdeclarativecontext_p.h42
1 files changed, 34 insertions, 8 deletions
diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h
index fb6473cb7a..92aa7bfafb 100644
--- a/src/declarative/qml/qdeclarativecontext_p.h
+++ b/src/declarative/qml/qdeclarativecontext_p.h
@@ -67,10 +67,12 @@
#include <QtCore/qset.h>
#include <private/qobject_p.h>
-#include "qdeclarativeguard_p.h"
+#include <private/qflagpointer_p.h>
+#include <private/qdeclarativeguard_p.h>
#include <private/qv8_p.h>
+
QT_BEGIN_NAMESPACE
class QV8Bindings;
@@ -184,13 +186,13 @@ public:
// id guards
struct ContextGuard : public QDeclarativeGuard<QObject>
{
- ContextGuard() : context(0) {}
- inline ContextGuard &operator=(QObject *obj)
- { QDeclarativeGuard<QObject>::operator=(obj); return *this; }
- virtual void objectDestroyed(QObject *) {
- if (context->contextObject && !QObjectPrivate::get(context->contextObject)->wasDeleted) bindings.notify();
- }
- QDeclarativeContextData *context;
+ inline ContextGuard();
+ inline ContextGuard &operator=(QObject *obj);
+ inline void objectDestroyed(QObject *);
+
+ inline bool wasSet() const;
+
+ QFlagPointer<QDeclarativeContextData> context;
QDeclarativeNotifier bindings;
};
ContextGuard *idValues;
@@ -302,6 +304,30 @@ QDeclarativeGuardedContextData::operator=(QDeclarativeContextData *d)
return *this;
}
+QDeclarativeContextData::ContextGuard::ContextGuard()
+: context(0)
+{
+}
+
+QDeclarativeContextData::ContextGuard &QDeclarativeContextData::ContextGuard::operator=(QObject *obj)
+{
+ QDeclarativeGuard<QObject>::operator=(obj);
+ context.setFlag();
+ bindings.notify(); // For alias connections
+ return *this;
+}
+
+void QDeclarativeContextData::ContextGuard::objectDestroyed(QObject *)
+{
+ if (context->contextObject && !QObjectPrivate::get(context->contextObject)->wasDeleted)
+ bindings.notify();
+}
+
+bool QDeclarativeContextData::ContextGuard::wasSet() const
+{
+ return context.flag();
+}
+
QT_END_NAMESPACE
#endif // QDECLARATIVECONTEXT_P_H