diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-09-15 08:19:28 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-09-15 08:19:28 (GMT) |
commit | 83d3085841b2caadb15c2534b1a2e329949f748d (patch) | |
tree | 8c1d3aa2046055b660832cd27fdb254954a87a5d /src/declarative/qml/qdeclarativenotifier_p.h | |
parent | 44d30ae2968846bd820b8bb5d1128a8b7a2d4207 (diff) | |
download | Qt-83d3085841b2caadb15c2534b1a2e329949f748d.zip Qt-83d3085841b2caadb15c2534b1a2e329949f748d.tar.gz Qt-83d3085841b2caadb15c2534b1a2e329949f748d.tar.bz2 |
Fix aliasing bug when compiled with gcc 4.6
Task-number: QTBUG-21265
Diffstat (limited to 'src/declarative/qml/qdeclarativenotifier_p.h')
-rw-r--r-- | src/declarative/qml/qdeclarativenotifier_p.h | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/declarative/qml/qdeclarativenotifier_p.h b/src/declarative/qml/qdeclarativenotifier_p.h index 5f70f7d..e46b843 100644 --- a/src/declarative/qml/qdeclarativenotifier_p.h +++ b/src/declarative/qml/qdeclarativenotifier_p.h @@ -99,8 +99,15 @@ private: enum { InvalidType, SignalType, NotifierType } type; union { - char signalData[sizeof(Signal)]; - char notifierData[sizeof(Notifier)]; + struct { + Signal *signal; + union { + char signalData[sizeof(Signal)]; + qint64 q_for_alignment_1; + double q_for_alignment_2; + }; + }; + Notifier notifier; }; inline Notifier *toNotifier(); @@ -194,7 +201,7 @@ void QDeclarativeNotifierEndpoint::connect(QDeclarativeNotifier *notifier) void QDeclarativeNotifierEndpoint::disconnect() { if (type == SignalType) { - Signal *s = (Signal *)&signalData; + Signal *s = asSignal(); if (s->source) { QMetaObject::disconnectOne(s->source, s->sourceSignal, target, targetMethod); s->source = 0; @@ -234,7 +241,8 @@ QDeclarativeNotifierEndpoint::Notifier *QDeclarativeNotifierEndpoint::toNotifier QDeclarativeNotifierEndpoint::Notifier *QDeclarativeNotifierEndpoint::asNotifier() { - return (Notifier *)(¬ifierData); + Q_ASSERT(type == NotifierType); + return ¬ifier; } QDeclarativeNotifierEndpoint::Signal *QDeclarativeNotifierEndpoint::toSignal() @@ -243,16 +251,15 @@ QDeclarativeNotifierEndpoint::Signal *QDeclarativeNotifierEndpoint::toSignal() return asSignal(); disconnect(); - Signal *s = asSignal(); - new (s) Signal; + signal = new (&signalData) Signal; type = SignalType; - - return s; + return signal; } QDeclarativeNotifierEndpoint::Signal *QDeclarativeNotifierEndpoint::asSignal() { - return (Signal *)(&signalData); + Q_ASSERT(type == SignalType); + return signal; } QT_END_NAMESPACE |