Commit 0befb98c authored by Lasse Holmstedt's avatar Lasse Holmstedt
Browse files

Fixed crash when opening ui files in design mode

QML Designer now listens to contextChanged signal instead of
modeChanged and checks that the context is same as that of qmldesigner.

Reviewed-by: con
parent 4f4bbe98
......@@ -174,6 +174,11 @@ QStringList DesignMode::registeredMimeTypes() const
return rc;
}
/**
* Registers a widget to be displayed when an editor with a file specified in
* mimeTypes is opened. This also appends the additionalContext in ICore to
* the context, specified here.
*/
void DesignMode::registerDesignWidget(QWidget *widget,
const QStringList &mimeTypes,
const QList<int> &context,
......
......@@ -159,7 +159,8 @@ void DesignModeWidget::showEditor(Core::IEditor *editor)
fileName = editor->file()->fileName();
textEdit = qobject_cast<QPlainTextEdit*>(editor->widget());
textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
m_fakeToolBar->addEditor(textEditor);
if (textEditor)
m_fakeToolBar->addEditor(textEditor);
}
if (debug)
......
......@@ -43,6 +43,7 @@
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/icore.h>
#include <coreplugin/icontext.h>
#include <coreplugin/dialogs/iwizard.h>
#include <coreplugin/editormanager/ieditorfactory.h>
#include <coreplugin/editormanager/editormanager.h>
......@@ -227,8 +228,9 @@ void BauhausPlugin::createDesignModeWidget()
connect(m_editorManager, SIGNAL(editorsClosed(QList<Core::IEditor*>)),
this, SLOT(textEditorsClosed(QList<Core::IEditor*>)));
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
this, SLOT(modeChanged(Core::IMode*)));
connect(creatorCore, SIGNAL(contextChanged(Core::IContext*,QList<int>)),
this, SLOT(contextChanged(Core::IContext*,QList<int>)));
}
void BauhausPlugin::updateEditor(Core::IEditor *editor)
......@@ -241,17 +243,22 @@ void BauhausPlugin::updateEditor(Core::IEditor *editor)
}
}
void BauhausPlugin::modeChanged(Core::IMode *mode)
void BauhausPlugin::contextChanged(Core::IContext *context, const QList<int> &additionalContexts)
{
if (mode == m_designMode) {
m_isActive = true;
m_mainWidget->showEditor(m_editorManager->currentEditor());
} else {
if (m_isActive) {
m_isActive = false;
m_mainWidget->showEditor(0);
Q_UNUSED(context)
foreach(int additionalContext, additionalContexts) {
if (m_context->context().contains(additionalContext)) {
m_isActive = true;
m_mainWidget->showEditor(m_editorManager->currentEditor());
return;
}
}
if (m_isActive) {
m_isActive = false;
m_mainWidget->showEditor(0);
}
}
void BauhausPlugin::textEditorsClosed(QList<Core::IEditor*> editors)
......
......@@ -42,6 +42,7 @@ class QAction;
QT_END_NAMESPACE
namespace Core {
class IContext;
class IWizard;
class ICore;
class IEditorFactory;
......@@ -84,7 +85,7 @@ private slots:
void textEditorsClosed(QList<Core::IEditor *> editors);
void updateActions(Core::IEditor* editor);
void updateEditor(Core::IEditor *editor);
void modeChanged(Core::IMode *mode);
void contextChanged(Core::IContext *context, const QList<int> &additionalContexts);
private:
void createDesignModeWidget();
......
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