Commit dc2b0c49 authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Fix crash for in document handling

Detach rewriter for document switching.

Change-Id: I4cc710990d01b30da25609961b81b07e785a26eb
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 78076ed8
......@@ -284,7 +284,7 @@ void DesignDocument::resetToDocumentModel()
m_rewriterView->setTextModifier(m_documentTextModifier.data());
}
QList<RewriterView::Error> DesignDocument::loadDocument(QPlainTextEdit *edit)
void DesignDocument::loadDocument(QPlainTextEdit *edit)
{
Q_CHECK_PTR(edit);
......@@ -305,9 +305,7 @@ QList<RewriterView::Error> DesignDocument::loadDocument(QPlainTextEdit *edit)
m_subComponentManager->update(QUrl::fromLocalFile(fileName()), m_currentModel->imports());
activateCurrentModel(m_documentTextModifier.data());
return rewriterView()->errors();
m_documentLoaded = true;
}
void DesignDocument::changeCurrentModelTo(const ModelNode &node)
......@@ -391,37 +389,14 @@ void DesignDocument::activateCurrentModel(TextModifier *textModifier)
// !differentCrumbleBarOnTop(m_formEditorView.data(), createCrumbleBarInfo().value<CrumbleBarInfo>()))
// m_formEditorView->crumblePath()->pushElement(simplfiedDisplayName(), createCrumbleBarInfo());
m_documentLoaded = true;
Q_ASSERT(m_documentModel);
QApplication::restoreOverrideCursor();
}
void DesignDocument::activateCurrentModel()
{
if (currentModel() == documentModel())
activateCurrentModel(m_documentTextModifier.data());
else
activateCurrentModel(m_inFileComponentTextModifier.data());
}
void DesignDocument::activateDocumentModel()
{
//this function seems to be unused!
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
Q_ASSERT(m_documentModel);
Q_ASSERT(m_currentModel);
if (!plainTextEdit()->parent()) // hack to prevent changing owner of external text edit
m_stackedWidget->addWidget(plainTextEdit());
m_currentModel = m_documentModel;
m_documentLoaded = true;
updateSubcomponentManager();
Q_ASSERT(m_documentModel);
QApplication::restoreOverrideCursor();
activateCurrentModel(m_documentTextModifier.data());
}
bool DesignDocument::isUndoAvailable() const
......
......@@ -77,9 +77,8 @@ public:
QString displayName() const;
QString simplfiedDisplayName() const;
QList<RewriterView::Error> loadDocument(QPlainTextEdit *edit);
void loadDocument(QPlainTextEdit *edit);
void activateCurrentModel(TextModifier *textModifier);
void activateCurrentModel();
void activateDocumentModel();
void close();
void updateSubcomponentManager();
......
......@@ -284,10 +284,10 @@ void QmlDesignerPlugin::activateAutoSynchronization()
// text editor -> visual editor
if (!currentDesignDocument()->isDocumentLoaded()) {
currentDesignDocument()->loadDocument(currentDesignDocument()->plainTextEdit());
} else {
currentDesignDocument()->activateCurrentModel();
}
currentDesignDocument()->activateDocumentModel();
resetModelSelection();
......@@ -298,6 +298,7 @@ void QmlDesignerPlugin::activateAutoSynchronization()
selectModelNodeUnderTextCursor();
m_mainWidget->enableWidgets();
} else {
viewManager().detachRewriterView();
m_mainWidget->disableWidgets();
m_mainWidget->showErrorMessage(errors);
}
......@@ -314,6 +315,8 @@ void QmlDesignerPlugin::deactivateAutoSynchronization()
{
viewManager().detachViewsExceptRewriterAndComponetView();
viewManager().detachComponentView();
viewManager().detachRewriterView();
documentManager().currentDesignDocument()->resetToDocumentModel();
disconnect(currentDesignDocument()->rewriterView(),
SIGNAL(errorsChanged(QList<RewriterView::Error>)),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment