diff options
author | Eike Ziller <eike.ziller@nokia.com> | 2012-05-07 15:18:39 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@nokia.com> | 2012-05-07 15:18:39 +0200 |
commit | 529c0a8fe203ec3288dc9f3053a806f53665d252 (patch) | |
tree | d71f907b13ccdd5a19dd0984986d4a3af1c172ac /src/plugins/texteditor | |
parent | d7f6bc336982b7175c1651ccc8dfd04dd79ea367 (diff) | |
parent | b63135c067d49a96c56195f75e7a6637c97c0702 (diff) | |
download | qt-creator-529c0a8fe203ec3288dc9f3053a806f53665d252.tar.gz |
Merge remote-tracking branch 'origin/2.5'
Diffstat (limited to 'src/plugins/texteditor')
-rw-r--r-- | src/plugins/texteditor/basetextmark.cpp | 16 | ||||
-rw-r--r-- | src/plugins/texteditor/basetextmark.h | 3 | ||||
-rw-r--r-- | src/plugins/texteditor/plaintexteditorfactory.cpp | 3 |
3 files changed, 17 insertions, 5 deletions
diff --git a/src/plugins/texteditor/basetextmark.cpp b/src/plugins/texteditor/basetextmark.cpp index 6f5898a532..21b5f4cfe3 100644 --- a/src/plugins/texteditor/basetextmark.cpp +++ b/src/plugins/texteditor/basetextmark.cpp @@ -38,6 +38,7 @@ #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/documentmanager.h> #include <extensionsystem/pluginmanager.h> +#include <utils/qtcassert.h> using namespace TextEditor; using namespace TextEditor::Internal; @@ -70,9 +71,9 @@ void BaseTextMarkRegistry::add(BaseTextMark *mark) } } -void BaseTextMarkRegistry::remove(BaseTextMark *mark) +bool BaseTextMarkRegistry::remove(BaseTextMark *mark) { - m_marks[Utils::FileName::fromString(mark->fileName())].remove(mark); + return m_marks[Utils::FileName::fromString(mark->fileName())].remove(mark); } void BaseTextMarkRegistry::editorOpened(Core::IEditor *editor) @@ -132,13 +133,22 @@ void BaseTextMarkRegistry::allDocumentsRenamed(const QString &oldName, const QSt BaseTextMark::BaseTextMark(const QString &fileName, int lineNumber) : ITextMark(lineNumber), m_fileName(fileName) { +} + +// we need two phase initilization, since we are calling virtual methods +// of BaseTextMark in add() and also accessing widthFactor +// which might be set in the derived constructor +void BaseTextMark::init() +{ Internal::TextEditorPlugin::instance()->baseTextMarkRegistry()->add(this); } BaseTextMark::~BaseTextMark() { // oha we are deleted - Internal::TextEditorPlugin::instance()->baseTextMarkRegistry()->remove(this); + bool b = Internal::TextEditorPlugin::instance()->baseTextMarkRegistry()->remove(this); + // If you get a assertion in this line, init() was never called + QTC_CHECK(b) } void BaseTextMark::updateFileName(const QString &fileName) diff --git a/src/plugins/texteditor/basetextmark.h b/src/plugins/texteditor/basetextmark.h index 1b31724f2f..c3c8808bca 100644 --- a/src/plugins/texteditor/basetextmark.h +++ b/src/plugins/texteditor/basetextmark.h @@ -60,6 +60,7 @@ class TEXTEDITOR_EXPORT BaseTextMark : public TextEditor::ITextMark public: BaseTextMark(const QString &fileName, int lineNumber); + void init(); virtual ~BaseTextMark(); /// called if the filename of the document changed @@ -80,7 +81,7 @@ public: BaseTextMarkRegistry(QObject *parent); void add(BaseTextMark *mark); - void remove(BaseTextMark *mark); + bool remove(BaseTextMark *mark); private slots: void editorOpened(Core::IEditor *editor); void documentRenamed(Core::IDocument *document, const QString &oldName, const QString &newName); diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp index 2820a11cef..bbc2d6b066 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.cpp +++ b/src/plugins/texteditor/plaintexteditorfactory.cpp @@ -44,6 +44,7 @@ #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/infobar.h> +#include <QCoreApplication> #include <QDebug> using namespace TextEditor; @@ -72,7 +73,7 @@ Core::Id PlainTextEditorFactory::id() const QString PlainTextEditorFactory::displayName() const { - return tr(Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME); + return qApp->translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME); } Core::IEditor *PlainTextEditorFactory::createEditor(QWidget *parent) |