forked from qt-creator/qt-creator
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
This commit is contained in:
@@ -174,6 +174,11 @@ QStringList DesignMode::registeredMimeTypes() const
|
|||||||
return rc;
|
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,
|
void DesignMode::registerDesignWidget(QWidget *widget,
|
||||||
const QStringList &mimeTypes,
|
const QStringList &mimeTypes,
|
||||||
const QList<int> &context,
|
const QList<int> &context,
|
||||||
|
|||||||
@@ -159,7 +159,8 @@ void DesignModeWidget::showEditor(Core::IEditor *editor)
|
|||||||
fileName = editor->file()->fileName();
|
fileName = editor->file()->fileName();
|
||||||
textEdit = qobject_cast<QPlainTextEdit*>(editor->widget());
|
textEdit = qobject_cast<QPlainTextEdit*>(editor->widget());
|
||||||
textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
|
textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
|
||||||
m_fakeToolBar->addEditor(textEditor);
|
if (textEditor)
|
||||||
|
m_fakeToolBar->addEditor(textEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
#include <coreplugin/actionmanager/command.h>
|
#include <coreplugin/actionmanager/command.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/icontext.h>
|
||||||
#include <coreplugin/dialogs/iwizard.h>
|
#include <coreplugin/dialogs/iwizard.h>
|
||||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
@@ -227,8 +228,9 @@ void BauhausPlugin::createDesignModeWidget()
|
|||||||
connect(m_editorManager, SIGNAL(editorsClosed(QList<Core::IEditor*>)),
|
connect(m_editorManager, SIGNAL(editorsClosed(QList<Core::IEditor*>)),
|
||||||
this, SLOT(textEditorsClosed(QList<Core::IEditor*>)));
|
this, SLOT(textEditorsClosed(QList<Core::IEditor*>)));
|
||||||
|
|
||||||
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
|
connect(creatorCore, SIGNAL(contextChanged(Core::IContext*,QList<int>)),
|
||||||
this, SLOT(modeChanged(Core::IMode*)));
|
this, SLOT(contextChanged(Core::IContext*,QList<int>)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BauhausPlugin::updateEditor(Core::IEditor *editor)
|
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) {
|
Q_UNUSED(context)
|
||||||
m_isActive = true;
|
|
||||||
m_mainWidget->showEditor(m_editorManager->currentEditor());
|
foreach(int additionalContext, additionalContexts) {
|
||||||
} else {
|
if (m_context->context().contains(additionalContext)) {
|
||||||
if (m_isActive) {
|
m_isActive = true;
|
||||||
m_isActive = false;
|
m_mainWidget->showEditor(m_editorManager->currentEditor());
|
||||||
m_mainWidget->showEditor(0);
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_isActive) {
|
||||||
|
m_isActive = false;
|
||||||
|
m_mainWidget->showEditor(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BauhausPlugin::textEditorsClosed(QList<Core::IEditor*> editors)
|
void BauhausPlugin::textEditorsClosed(QList<Core::IEditor*> editors)
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class QAction;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
class IContext;
|
||||||
class IWizard;
|
class IWizard;
|
||||||
class ICore;
|
class ICore;
|
||||||
class IEditorFactory;
|
class IEditorFactory;
|
||||||
@@ -84,7 +85,7 @@ private slots:
|
|||||||
void textEditorsClosed(QList<Core::IEditor *> editors);
|
void textEditorsClosed(QList<Core::IEditor *> editors);
|
||||||
void updateActions(Core::IEditor* editor);
|
void updateActions(Core::IEditor* editor);
|
||||||
void updateEditor(Core::IEditor *editor);
|
void updateEditor(Core::IEditor *editor);
|
||||||
void modeChanged(Core::IMode *mode);
|
void contextChanged(Core::IContext *context, const QList<int> &additionalContexts);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createDesignModeWidget();
|
void createDesignModeWidget();
|
||||||
|
|||||||
Reference in New Issue
Block a user