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() ...@@ -284,7 +284,7 @@ void DesignDocument::resetToDocumentModel()
m_rewriterView->setTextModifier(m_documentTextModifier.data()); m_rewriterView->setTextModifier(m_documentTextModifier.data());
} }
QList<RewriterView::Error> DesignDocument::loadDocument(QPlainTextEdit *edit) void DesignDocument::loadDocument(QPlainTextEdit *edit)
{ {
Q_CHECK_PTR(edit); Q_CHECK_PTR(edit);
...@@ -305,9 +305,7 @@ QList<RewriterView::Error> DesignDocument::loadDocument(QPlainTextEdit *edit) ...@@ -305,9 +305,7 @@ QList<RewriterView::Error> DesignDocument::loadDocument(QPlainTextEdit *edit)
m_subComponentManager->update(QUrl::fromLocalFile(fileName()), m_currentModel->imports()); m_subComponentManager->update(QUrl::fromLocalFile(fileName()), m_currentModel->imports());
activateCurrentModel(m_documentTextModifier.data()); m_documentLoaded = true;
return rewriterView()->errors();
} }
void DesignDocument::changeCurrentModelTo(const ModelNode &node) void DesignDocument::changeCurrentModelTo(const ModelNode &node)
...@@ -391,37 +389,14 @@ void DesignDocument::activateCurrentModel(TextModifier *textModifier) ...@@ -391,37 +389,14 @@ void DesignDocument::activateCurrentModel(TextModifier *textModifier)
// !differentCrumbleBarOnTop(m_formEditorView.data(), createCrumbleBarInfo().value<CrumbleBarInfo>())) // !differentCrumbleBarOnTop(m_formEditorView.data(), createCrumbleBarInfo().value<CrumbleBarInfo>()))
// m_formEditorView->crumblePath()->pushElement(simplfiedDisplayName(), createCrumbleBarInfo()); // m_formEditorView->crumblePath()->pushElement(simplfiedDisplayName(), createCrumbleBarInfo());
m_documentLoaded = true;
Q_ASSERT(m_documentModel); Q_ASSERT(m_documentModel);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
void DesignDocument::activateCurrentModel()
{
if (currentModel() == documentModel())
activateCurrentModel(m_documentTextModifier.data());
else
activateCurrentModel(m_inFileComponentTextModifier.data());
}
void DesignDocument::activateDocumentModel() void DesignDocument::activateDocumentModel()
{ {
//this function seems to be unused! activateCurrentModel(m_documentTextModifier.data());
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();
} }
bool DesignDocument::isUndoAvailable() const bool DesignDocument::isUndoAvailable() const
......
...@@ -77,9 +77,8 @@ public: ...@@ -77,9 +77,8 @@ public:
QString displayName() const; QString displayName() const;
QString simplfiedDisplayName() const; QString simplfiedDisplayName() const;
QList<RewriterView::Error> loadDocument(QPlainTextEdit *edit); void loadDocument(QPlainTextEdit *edit);
void activateCurrentModel(TextModifier *textModifier); void activateCurrentModel(TextModifier *textModifier);
void activateCurrentModel();
void activateDocumentModel(); void activateDocumentModel();
void close(); void close();
void updateSubcomponentManager(); void updateSubcomponentManager();
......
...@@ -284,10 +284,10 @@ void QmlDesignerPlugin::activateAutoSynchronization() ...@@ -284,10 +284,10 @@ void QmlDesignerPlugin::activateAutoSynchronization()
// text editor -> visual editor // text editor -> visual editor
if (!currentDesignDocument()->isDocumentLoaded()) { if (!currentDesignDocument()->isDocumentLoaded()) {
currentDesignDocument()->loadDocument(currentDesignDocument()->plainTextEdit()); currentDesignDocument()->loadDocument(currentDesignDocument()->plainTextEdit());
} else {
currentDesignDocument()->activateCurrentModel();
} }
currentDesignDocument()->activateDocumentModel();
resetModelSelection(); resetModelSelection();
...@@ -298,6 +298,7 @@ void QmlDesignerPlugin::activateAutoSynchronization() ...@@ -298,6 +298,7 @@ void QmlDesignerPlugin::activateAutoSynchronization()
selectModelNodeUnderTextCursor(); selectModelNodeUnderTextCursor();
m_mainWidget->enableWidgets(); m_mainWidget->enableWidgets();
} else { } else {
viewManager().detachRewriterView();
m_mainWidget->disableWidgets(); m_mainWidget->disableWidgets();
m_mainWidget->showErrorMessage(errors); m_mainWidget->showErrorMessage(errors);
} }
...@@ -314,6 +315,8 @@ void QmlDesignerPlugin::deactivateAutoSynchronization() ...@@ -314,6 +315,8 @@ void QmlDesignerPlugin::deactivateAutoSynchronization()
{ {
viewManager().detachViewsExceptRewriterAndComponetView(); viewManager().detachViewsExceptRewriterAndComponetView();
viewManager().detachComponentView(); viewManager().detachComponentView();
viewManager().detachRewriterView();
documentManager().currentDesignDocument()->resetToDocumentModel();
disconnect(currentDesignDocument()->rewriterView(), disconnect(currentDesignDocument()->rewriterView(),
SIGNAL(errorsChanged(QList<RewriterView::Error>)), 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