forked from qt-creator/qt-creator
QmlDesigner: Improve error message on trying to edit empty component
Task-number: QDS-5308 Change-Id: I401a375443e2df52a2656a34ab4c650664b0df97 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -123,6 +123,9 @@ QTextDocument *ComponentTextModifier::textDocument() const
|
||||
|
||||
QString ComponentTextModifier::text() const
|
||||
{
|
||||
if (m_componentStartOffset == -1)
|
||||
return {};
|
||||
|
||||
QString txt(m_originalModifier->text());
|
||||
|
||||
const int leader = m_componentStartOffset - m_rootStartOffset;
|
||||
|
@@ -1044,6 +1044,15 @@ void TextToModelMerger::setupUsedImports()
|
||||
|
||||
Document::MutablePtr TextToModelMerger::createParsedDocument(const QUrl &url, const QString &data, QList<DocumentMessage> *errors)
|
||||
{
|
||||
if (data.isEmpty()) {
|
||||
if (errors) {
|
||||
QmlJS::DiagnosticMessage msg;
|
||||
msg.message = QObject::tr("Empty document");
|
||||
errors->append(DocumentMessage(msg, url));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
const QString fileName = url.toLocalFile();
|
||||
|
||||
Dialect dialect = ModelManagerInterface::guessLanguageOfFile(fileName);
|
||||
|
Reference in New Issue
Block a user