forked from qt-creator/qt-creator
Let the DesignMode recover when the qml contains an error on first load
If the qml contains an error on frist call of DesignDocumentController::loadMaster, we did not wire up the components to the model. If the user then fixed the qml, the Design mode widgets were 'enabled', but didn't contain any meaningful input. Fixed by always wiring up the components. Unfortunately this shows the 'default' model with just a Rectangle.
This commit is contained in:
@@ -332,10 +332,10 @@ QList<RewriterView::Error> DesignDocumentController::loadMaster(QPlainTextEdit *
|
||||
|
||||
//m_d->masterModel = Model::create(m_d->textModifier, m_d->searchPath, errors);
|
||||
|
||||
m_d->masterModel = Model::create("Item", 4, 6);
|
||||
m_d->masterModel = Model::create("Qt/Rectangle", 4, 6);
|
||||
m_d->masterModel->setFileUrl(m_d->searchPath);
|
||||
|
||||
m_d->subComponentModel = Model::create("Item", 4, 6);
|
||||
m_d->subComponentModel = Model::create("Qt/Rectangle", 4, 6);
|
||||
m_d->subComponentModel->setFileUrl(m_d->searchPath);
|
||||
|
||||
m_d->subComponentManager = new SubComponentManager(m_d->masterModel->metaInfo(), this);
|
||||
@@ -354,13 +354,9 @@ QList<RewriterView::Error> DesignDocumentController::loadMaster(QPlainTextEdit *
|
||||
m_d->masterModel->attachView(m_d->viewLogger.data());
|
||||
#endif
|
||||
|
||||
// m_d->masterModel->detachView(m_d->rewriterView.data());
|
||||
loadCurrentModel();
|
||||
|
||||
QList<RewriterView::Error> errors = m_d->rewriterView->errors();
|
||||
if (errors.isEmpty())
|
||||
loadCurrentModel();
|
||||
|
||||
return errors;
|
||||
return m_d->rewriterView->errors();
|
||||
}
|
||||
|
||||
void DesignDocumentController::changeCurrentModelTo(const ModelNode &componentNode)
|
||||
|
||||
@@ -356,6 +356,9 @@ void DocumentWidget::disable(const QList<RewriterView::Error> &errors)
|
||||
|
||||
void DocumentWidget::updateErrorStatus(const QList<RewriterView::Error> &errors)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << Q_FUNC_INFO << errors.count();
|
||||
|
||||
if (m_isDisabled && errors.isEmpty()) {
|
||||
enable();
|
||||
} else if (!errors.isEmpty()) {
|
||||
@@ -526,7 +529,6 @@ void DesignModeWidget::showEditor(Core::IEditor *editor)
|
||||
if (textEdit && textEditor && fileName.endsWith(".qml")) {
|
||||
if (m_documentHash.contains(textEdit)) {
|
||||
documentWidget = m_documentHash.value(textEdit);
|
||||
documentWidget->setAutoSynchronization(true);
|
||||
} else {
|
||||
DesignDocumentController *newDocument = new DesignDocumentController(0);
|
||||
newDocument->setFileName(fileName);
|
||||
@@ -659,6 +661,10 @@ void DesignModeWidget::setCurrentDocumentWidget(DocumentWidget *newDocumentWidge
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << Q_FUNC_INFO << newDocumentWidget;
|
||||
|
||||
if (m_currentDocumentWidget == newDocumentWidget)
|
||||
return;
|
||||
|
||||
if (m_currentDocumentWidget) {
|
||||
m_currentDocumentWidget->setAutoSynchronization(false);
|
||||
m_currentDocumentWidget->saveSettings();
|
||||
|
||||
Reference in New Issue
Block a user