Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Honour the resettable flag of aliased properties
Previously, alias properties were not considered isResettable even if the property they alias is resettable. This commit ensures that the IsResettable flag is set for alias properties iff the aliased property is resettable, and that it is honoured during property reset operations. Task-number: QTBUG-18182 Change-Id: I9cab11923a952df72e976a48489a78b24a34314f Reviewed-on: http://codereview.qt.nokia.com/1471 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
- Loading branch information
Chris Adams
authored and
Qt by Nokia
committed
Aug 4, 2011
1 parent
29af49f
commit fd68b86
Showing
10 changed files
with
238 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/AliasPropertyComponent.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import QtQuick 2.0 | ||
|
||
Item { | ||
id: apc | ||
property alias sourceComponent: loader.sourceComponent | ||
|
||
Component { | ||
id: redSquare | ||
Rectangle { color: "red"; width: 10; height: 10 } | ||
} | ||
|
||
Loader { | ||
id: loader | ||
objectName: "loader" | ||
sourceComponent: redSquare | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import QtQuick 1.0 | ||
import Qt.test 1.0 | ||
|
||
Item { | ||
id: first | ||
property bool aliasIsUndefined: false | ||
property alias sourceComponentAlias: loader.sourceComponent | ||
|
||
Component { | ||
id: redSquare | ||
Rectangle { color: "red"; width: 10; height: 10 } | ||
} | ||
|
||
Loader { | ||
id: loader | ||
sourceComponent: redSquare | ||
} | ||
|
||
function resetAliased() { | ||
loader.sourceComponent = undefined; | ||
aliasIsUndefined = (sourceComponentAlias == undefined); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import QtQuick 1.0 | ||
import Qt.test 1.0 | ||
|
||
Item { | ||
id: first | ||
property bool loaderSourceComponentIsUndefined: false | ||
property alias sourceComponentAlias: loader.sourceComponent | ||
|
||
Component { | ||
id: redSquare | ||
Rectangle { color: "red"; width: 10; height: 10 } | ||
} | ||
|
||
Loader { | ||
id: loader | ||
sourceComponent: redSquare | ||
} | ||
|
||
function resetAlias() { | ||
sourceComponentAlias = undefined; | ||
loaderSourceComponentIsUndefined = (loader.sourceComponent == undefined); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import QtQuick 1.0 | ||
import Qt.test 1.0 | ||
|
||
Item { | ||
id: first | ||
property bool loaderTwoSourceComponentIsUndefined: false | ||
property bool loaderOneSourceComponentIsUndefined: false | ||
property alias sourceComponentAlias: loaderOne.sourceComponent | ||
|
||
Component { | ||
id: redSquare | ||
Rectangle { color: "red"; width: 10; height: 10 } | ||
} | ||
|
||
Loader { | ||
id: loaderOne | ||
sourceComponent: loaderTwo.sourceComponent | ||
} | ||
|
||
Loader { | ||
id: loaderTwo | ||
sourceComponent: redSquare | ||
x: 15 | ||
} | ||
|
||
function resetAlias() { | ||
sourceComponentAlias = undefined; // loaderOne.sourceComponent should be set to undefined instead of l2.sc | ||
loaderOneSourceComponentIsUndefined = (loaderOne.sourceComponent == undefined); // should be true | ||
loaderTwoSourceComponentIsUndefined = (loaderTwo.sourceComponent == undefined); // should be false | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import QtQuick 1.0 | ||
import Qt.test 1.0 | ||
|
||
Item { | ||
id: first | ||
property alias sourceComponentAlias: loader.sourceComponent | ||
|
||
Component { | ||
id: redSquare | ||
Rectangle { color: "red"; width: 10; height: 10 } | ||
} | ||
|
||
Loader { | ||
id: loader | ||
objectName: "loader" | ||
sourceComponent: redSquare | ||
} | ||
|
||
function resetAlias() { | ||
sourceComponentAlias = undefined; // ensure we don't crash after deletion of loader. | ||
} | ||
|
||
function setAlias() { | ||
sourceComponentAlias = redSquare; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import QtQuick 1.0 | ||
import Qt.test 1.0 | ||
|
||
Item { | ||
id: root | ||
|
||
AliasPropertyComponent { | ||
sourceComponent: returnsUndefined() | ||
} | ||
|
||
function returnsUndefined() { | ||
return undefined; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import QtQuick 1.0 | ||
import Qt.test 1.0 | ||
|
||
MyQmlObject { | ||
id: first | ||
property bool aliasedIntIsUndefined: false | ||
property alias intAlias: objprop.intp | ||
|
||
objectProperty: QtObject { | ||
id: objprop | ||
property int intp: 12 | ||
} | ||
|
||
function resetAlias() { | ||
intAlias = undefined; // should error | ||
aliasedIntIsUndefined = (objprop.intp == undefined); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters