forked from qt-creator/qt-creator
TextEditor: Fix failure in cpptools autotest
The issue only appeared in the test due to the different editor construction there. Now use the same factory access. Change-Id: I3a8534fbe683bb88f04ad68850cecdfe32b11433 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include <coreplugin/coreconstants.h>
|
||||
|
||||
#include <texteditor/basetexteditor.h>
|
||||
#include <texteditor/plaintexteditorfactory.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
@@ -102,23 +103,20 @@ public:
|
||||
QVERIFY(ast);
|
||||
|
||||
// Open file
|
||||
TextEditor::BaseTextDocumentPtr textDocument(new TextEditor::BaseTextDocument);
|
||||
textDocument->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
||||
TextEditor::BaseTextEditorWidget editorWidget(0);
|
||||
editorWidget.setTextDocument(textDocument);
|
||||
editorWidget.setupAsPlainEditor();
|
||||
TextEditor::BaseTextEditor *editor = TextEditor::PlainTextEditorFactory::createPlainTextEditor();
|
||||
TextEditor::BaseTextEditorWidget *editorWidget = editor->editorWidget();
|
||||
QString error;
|
||||
editorWidget.open(&error, document->fileName(), document->fileName());
|
||||
editor->open(&error, document->fileName(), document->fileName());
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
// Set cursor position
|
||||
QTextCursor cursor = editorWidget.textCursor();
|
||||
QTextCursor cursor = editorWidget->textCursor();
|
||||
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, cursorPosition);
|
||||
editorWidget.setTextCursor(cursor);
|
||||
editorWidget->setTextCursor(cursor);
|
||||
|
||||
QTextDocument *qtextDocument = editorWidget.document();
|
||||
QTextDocument *qtextDocument = editorWidget->document();
|
||||
CppRefactoringFilePtr cppRefactoringFile
|
||||
= CppRefactoringChanges::file(&editorWidget, document);
|
||||
= CppRefactoringChanges::file(editorWidget, document);
|
||||
|
||||
// Prepare for formatting
|
||||
Overview overview;
|
||||
|
||||
@@ -77,19 +77,21 @@ namespace Internal {
|
||||
class TextEditorOverlay;
|
||||
}
|
||||
|
||||
class BaseTextEditorWidget;
|
||||
class AutoCompleter;
|
||||
class BaseTextEditor;
|
||||
class BaseTextEditorFactory;
|
||||
class FontSettings;
|
||||
class BaseTextEditorWidget;
|
||||
class PlainTextEditorFactory;
|
||||
|
||||
class BehaviorSettings;
|
||||
class CompletionSettings;
|
||||
class DisplaySettings;
|
||||
class MarginSettings;
|
||||
class TypingSettings;
|
||||
class StorageSettings;
|
||||
class Indenter;
|
||||
class AutoCompleter;
|
||||
class ExtraEncodingSettings;
|
||||
class BaseTextEditor;
|
||||
class FontSettings;
|
||||
class Indenter;
|
||||
class MarginSettings;
|
||||
class StorageSettings;
|
||||
class TypingSettings;
|
||||
|
||||
class TEXTEDITOR_EXPORT BlockRange
|
||||
{
|
||||
@@ -640,6 +642,7 @@ public:
|
||||
|
||||
private:
|
||||
friend class BaseTextEditor;
|
||||
friend class PlainTextEditorFactory;
|
||||
|
||||
Core::IEditor *createEditor();
|
||||
BaseTextEditor *createEditorHelper(const BaseTextDocumentPtr &doc);
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "highlightersettings.h"
|
||||
#include <texteditor/plaintexteditorfactory.h>
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
#include <texteditor/texteditorplugin.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
@@ -359,7 +358,7 @@ void Manager::registerMimeTypesFinished()
|
||||
const QPair<RegisterData, QList<MimeType> > &result = m_registeringWatcher.result();
|
||||
m_register = result.first;
|
||||
|
||||
PlainTextEditorFactory *factory = TextEditorPlugin::editorFactory();
|
||||
PlainTextEditorFactory *factory = PlainTextEditorFactory::instance();
|
||||
const QSet<QString> &inFactory = factory->mimeTypes().toSet();
|
||||
foreach (const MimeType &mimeType, result.second) {
|
||||
MimeDatabase::addMimeType(mimeType);
|
||||
|
||||
@@ -41,10 +41,10 @@
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
namespace TextEditor {
|
||||
namespace Internal {
|
||||
|
||||
static PlainTextEditorFactory *m_instance = 0;
|
||||
|
||||
class PlainTextEditorWidget : public BaseTextEditorWidget
|
||||
{
|
||||
@@ -55,6 +55,8 @@ public:
|
||||
|
||||
PlainTextEditorFactory::PlainTextEditorFactory()
|
||||
{
|
||||
QTC_CHECK(!m_instance);
|
||||
m_instance = this;
|
||||
setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
||||
setDisplayName(qApp->translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME));
|
||||
addMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
|
||||
@@ -69,5 +71,14 @@ PlainTextEditorFactory::PlainTextEditorFactory()
|
||||
TextEditorActionHandler::UnCollapseAll);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
PlainTextEditorFactory *PlainTextEditorFactory::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
BaseTextEditor *PlainTextEditorFactory::createPlainTextEditor()
|
||||
{
|
||||
return qobject_cast<BaseTextEditor *>(m_instance->createEditor());
|
||||
}
|
||||
|
||||
} // namespace TextEditor
|
||||
|
||||
@@ -33,17 +33,17 @@
|
||||
#include <texteditor/basetexteditor.h>
|
||||
|
||||
namespace TextEditor {
|
||||
namespace Internal {
|
||||
|
||||
class PlainTextEditorFactory : public TextEditor::BaseTextEditorFactory
|
||||
class TEXTEDITOR_EXPORT PlainTextEditorFactory : public TextEditor::BaseTextEditorFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PlainTextEditorFactory();
|
||||
static PlainTextEditorFactory *instance();
|
||||
static BaseTextEditor *createPlainTextEditor();
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace TextEditor
|
||||
|
||||
#endif // PLAINTEXTEDITORFACTORY_H
|
||||
|
||||
@@ -70,7 +70,6 @@ static TextEditorPlugin *m_instance = 0;
|
||||
|
||||
TextEditorPlugin::TextEditorPlugin()
|
||||
: m_settings(0),
|
||||
m_editorFactory(0),
|
||||
m_lineNumberFilter(0),
|
||||
m_searchResultWindow(0)
|
||||
{
|
||||
@@ -154,8 +153,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
m_settings = new TextEditorSettings(this);
|
||||
|
||||
// Add plain text editor factory
|
||||
m_editorFactory = new PlainTextEditorFactory;
|
||||
addAutoReleasedObject(m_editorFactory);
|
||||
addAutoReleasedObject(new PlainTextEditorFactory);
|
||||
|
||||
// Goto line functionality for quick open
|
||||
m_lineNumberFilter = new LineNumberFilter;
|
||||
@@ -261,11 +259,6 @@ void TextEditorPlugin::extensionsInitialized()
|
||||
this, SLOT(updateCurrentSelection(QString)));
|
||||
}
|
||||
|
||||
PlainTextEditorFactory *TextEditorPlugin::editorFactory()
|
||||
{
|
||||
return m_instance->m_editorFactory;
|
||||
}
|
||||
|
||||
LineNumberFilter *TextEditorPlugin::lineNumberFilter()
|
||||
{
|
||||
return m_instance->m_lineNumberFilter;
|
||||
|
||||
@@ -42,7 +42,6 @@ class TextEditorSettings;
|
||||
namespace Internal {
|
||||
|
||||
class LineNumberFilter;
|
||||
class PlainTextEditorFactory;
|
||||
class OutlineFactory;
|
||||
class TextMarkRegistry;
|
||||
|
||||
@@ -59,7 +58,6 @@ public:
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage);
|
||||
void extensionsInitialized();
|
||||
|
||||
static PlainTextEditorFactory *editorFactory();
|
||||
static LineNumberFilter *lineNumberFilter();
|
||||
static TextMarkRegistry *baseTextMarkRegistry();
|
||||
|
||||
@@ -71,7 +69,6 @@ private slots:
|
||||
|
||||
private:
|
||||
TextEditorSettings *m_settings;
|
||||
PlainTextEditorFactory *m_editorFactory;
|
||||
LineNumberFilter *m_lineNumberFilter;
|
||||
Core::SearchResultWindow *m_searchResultWindow;
|
||||
OutlineFactory *m_outlineFactory;
|
||||
|
||||
Reference in New Issue
Block a user