Skip to content

Commit f079ac9

Browse files
author
Qt Continuous Integration System
committed
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Fix crash on exit when overriding signal handlers in states.
2 parents a08b8d5 + 93c64e1 commit f079ac9

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

src/declarative/util/qdeclarativepropertychanges.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ class QDeclarativeReplaceSignalHandler : public QDeclarativeActionEvent
171171
reverseExpression = rewindExpression;
172172
}
173173

174-
/*virtual void copyOriginals(QDeclarativeActionEvent *other)
174+
virtual bool needsCopy() { return true; }
175+
virtual void copyOriginals(QDeclarativeActionEvent *other)
175176
{
176177
QDeclarativeReplaceSignalHandler *rsh = static_cast<QDeclarativeReplaceSignalHandler*>(other);
177178
saveCurrentValues();
@@ -182,7 +183,7 @@ class QDeclarativeReplaceSignalHandler : public QDeclarativeActionEvent
182183
ownedExpression = rsh->ownedExpression;
183184
rsh->ownedExpression = 0;
184185
}
185-
}*/
186+
}
186187

187188
virtual void rewind() {
188189
ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import QtQuick 1.0
2+
3+
Rectangle {
4+
id: myRect
5+
width: 400
6+
height: 400
7+
8+
onHeightChanged: console.log("base state")
9+
10+
states: [
11+
State {
12+
name: "state1"
13+
PropertyChanges {
14+
target: myRect
15+
onHeightChanged: console.log("state1")
16+
color: "green"
17+
}
18+
},
19+
State {
20+
name: "state2";
21+
PropertyChanges {
22+
target: myRect
23+
onHeightChanged: console.log("state2")
24+
color: "red"
25+
}
26+
}]
27+
}

tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ private slots:
113113
void signalOverride();
114114
void signalOverrideCrash();
115115
void signalOverrideCrash2();
116+
void signalOverrideCrash3();
116117
void parentChange();
117118
void parentChangeErrors();
118119
void anchorChanges();
@@ -520,6 +521,22 @@ void tst_qdeclarativestates::signalOverrideCrash2()
520521
delete rect;
521522
}
522523

524+
void tst_qdeclarativestates::signalOverrideCrash3()
525+
{
526+
QDeclarativeEngine engine;
527+
528+
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash3.qml");
529+
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
530+
QVERIFY(rect != 0);
531+
532+
QDeclarativeItemPrivate::get(rect)->setState("state1");
533+
QDeclarativeItemPrivate::get(rect)->setState("");
534+
QDeclarativeItemPrivate::get(rect)->setState("state2");
535+
QDeclarativeItemPrivate::get(rect)->setState("");
536+
537+
delete rect;
538+
}
539+
523540
void tst_qdeclarativestates::parentChange()
524541
{
525542
QDeclarativeEngine engine;

0 commit comments

Comments
 (0)