forked from qt-creator/qt-creator
QmlJS: Add error message for invalid root item in the designer
Documents with those types do crash the qmlpuppet and confuse the users. With this patch we give a clear error message and such files are not supported anymore. Change-Id: Iba19def2751d4dc81d90684c0c63c0274fdf49cf Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
@@ -525,10 +525,24 @@ public:
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class UnsupportedRootObjectTypesByVisualDesigner : public QStringList
|
||||
{
|
||||
public:
|
||||
UnsupportedRootObjectTypesByVisualDesigner()
|
||||
{
|
||||
(*this) << QLatin1String("QtObject") << QLatin1String("ListModel")
|
||||
<< QLatin1String("Component") << QLatin1String("Timer")
|
||||
<< QLatin1String("Package");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // end of anonymous namespace
|
||||
|
||||
Q_GLOBAL_STATIC(VisualAspectsPropertyBlackList, visualAspectsPropertyBlackList)
|
||||
Q_GLOBAL_STATIC(UnsupportedTypesByVisualDesigner, unsupportedTypesByVisualDesigner)
|
||||
Q_GLOBAL_STATIC(UnsupportedRootObjectTypesByVisualDesigner, unsupportedRootObjectTypesByVisualDesigner)
|
||||
|
||||
Check::Check(Document::Ptr doc, const ContextPtr &context)
|
||||
: _doc(doc)
|
||||
@@ -559,6 +573,7 @@ Check::Check(Document::Ptr doc, const ContextPtr &context)
|
||||
disableMessage(WarnReferenceToParentItemNotSupportedByVisualDesigner);
|
||||
disableMessage(WarnUndefinedValueForVisualDesigner);
|
||||
disableMessage(WarnStatesOnlyInRootItemForVisualDesigner);
|
||||
disableMessage(ErrUnsupportedRootTypeInVisualDesigner);
|
||||
}
|
||||
|
||||
Check::~Check()
|
||||
@@ -729,6 +744,13 @@ void Check::visitQmlObject(Node *ast, UiQualifiedId *typeId,
|
||||
if (m_typeStack.count() > 1 && getRightMostIdentifier(typeId)->name.toString() == QLatin1String("State"))
|
||||
addMessage(WarnStatesOnlyInRootItemForVisualDesigner, typeErrorLocation);
|
||||
|
||||
const QString typeName = getRightMostIdentifier(typeId)->name.toString();
|
||||
|
||||
if (m_typeStack.isEmpty()
|
||||
&& unsupportedRootObjectTypesByVisualDesigner()->contains(typeName))
|
||||
addMessage(ErrUnsupportedRootTypeInVisualDesigner,
|
||||
locationFromRange(ast->firstSourceLocation(), ast->lastSourceLocation()), typeName);
|
||||
|
||||
bool typeError = false;
|
||||
if (_importsOk) {
|
||||
const ObjectValue *prototype = _context->lookupType(_doc.data(), typeId);
|
||||
|
Reference in New Issue
Block a user