Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
e615cf82
Commit
e615cf82
authored
Apr 06, 2010
by
Erik Verbruggen
Browse files
Fixed regression when assigning an object binding to an array property.
parent
d1602650
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/libs/qmljs/qmljsinterpreter.cpp
View file @
e615cf82
...
...
@@ -187,6 +187,9 @@ public:
QString
typeName
()
const
{
return
m_type
;
}
bool
isList
()
const
{
return
m_isList
;
}
};
class
FakeMetaObject
{
...
...
@@ -859,6 +862,15 @@ QString QmlObjectValue::propertyType(const QString &propertyName) const
return
QString
();
}
bool
QmlObjectValue
::
isListProperty
(
const
QString
&
name
)
const
{
int
idx
=
_metaObject
->
propertyIndex
(
name
);
if
(
idx
==
-
1
)
return
false
;
FakeMetaProperty
prop
=
_metaObject
->
property
(
idx
);
return
prop
.
isList
();
}
bool
QmlObjectValue
::
isEnum
(
const
QString
&
typeName
)
const
{
return
_metaObject
->
enumeratorIndex
(
typeName
)
!=
-
1
;
...
...
src/libs/qmljs/qmljsinterpreter.h
View file @
e615cf82
...
...
@@ -418,6 +418,7 @@ public:
int
minorVersion
()
const
;
QString
defaultPropertyName
()
const
;
QString
propertyType
(
const
QString
&
propertyName
)
const
;
bool
isListProperty
(
const
QString
&
name
)
const
;
bool
isEnum
(
const
QString
&
typeName
)
const
;
protected:
...
...
src/plugins/qmldesigner/core/model/texttomodelmerger.cpp
View file @
e615cf82
...
...
@@ -303,15 +303,23 @@ public:
return
true
;
}
bool
isArrayProperty
(
const
Interpreter
::
Value
*
value
)
bool
isArrayProperty
(
const
Interpreter
::
Value
*
value
,
const
Interpreter
::
ObjectValue
*
containingObject
,
const
QString
&
name
)
{
if
(
!
value
)
return
false
;
const
Interpreter
::
ObjectValue
*
objectValue
=
value
->
asObjectValue
();
if
(
!
objectValue
)
return
fals
e
;
if
(
objectValue
&&
objectValue
->
prototype
(
m_context
)
==
m_engine
->
arrayPrototype
()
)
return
tru
e
;
return
objectValue
->
prototype
(
m_context
)
==
m_engine
->
arrayPrototype
();
for
(
const
Interpreter
::
ObjectValue
*
iter
=
containingObject
;
iter
;
iter
=
iter
->
prototype
(
m_context
))
{
if
(
iter
->
property
(
name
,
m_context
)
==
m_engine
->
arrayPrototype
())
return
true
;
if
(
const
Interpreter
::
QmlObjectValue
*
qmlIter
=
dynamic_cast
<
const
Interpreter
::
QmlObjectValue
*>
(
iter
))
{
if
(
qmlIter
->
isListProperty
(
name
))
return
true
;
}
}
return
false
;
}
QVariant
convertToVariant
(
const
QString
&
astValue
,
UiQualifiedId
*
propertyId
)
...
...
@@ -580,10 +588,12 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
if
(
binding
->
hasOnToken
)
{
// skip value sources
}
else
{
const
Interpreter
::
Value
*
propertyType
;
if
(
context
->
lookupProperty
(
binding
->
qualifiedId
,
&
propertyType
)
||
typeName
==
QLatin1String
(
"Qt/PropertyChanges"
))
{
const
Interpreter
::
Value
*
propertyType
=
0
;
const
Interpreter
::
ObjectValue
*
containingObject
=
0
;
QString
name
;
if
(
context
->
lookupProperty
(
binding
->
qualifiedId
,
&
propertyType
,
&
containingObject
,
&
name
)
||
typeName
==
QLatin1String
(
"Qt/PropertyChanges"
))
{
AbstractProperty
modelProperty
=
modelNode
.
property
(
astPropertyName
);
if
(
context
->
isArrayProperty
(
propertyType
))
{
if
(
context
->
isArrayProperty
(
propertyType
,
containingObject
,
name
))
{
syncArrayProperty
(
modelProperty
,
QList
<
QmlJS
::
AST
::
UiObjectMember
*>
()
<<
member
,
context
,
differenceHandler
);
}
else
{
syncNodeProperty
(
modelProperty
,
binding
,
context
,
differenceHandler
);
...
...
tests/auto/qml/qmldesigner/coretests/testcore.cpp
View file @
e615cf82
...
...
@@ -133,7 +133,6 @@ void TestCore::testModelCreateCoreModel()
// TODO: this need to e updated for states
void
TestCore
::
loadEmptyCoreModel
()
{
QList
<
QDeclarativeError
>
errors
;
QFile
file
(
":/fx/empty.qml"
);
QVERIFY
(
file
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment