From eb74931dd7ea289600f21585f21ff04bbb7b18e0 Mon Sep 17 00:00:00 2001 From: Leandro Melo Date: Thu, 15 Mar 2012 11:54:12 -0300 Subject: Editor: Fix crash in generic highlighter Add a method for basic structural checks of a definition. Currently it simply tests for a initial context. Task-number: QTCREATORBUG-7053 Change-Id: I56415034b50908d6da5f66ffab7def8fdd5fa1fb Reviewed-by: David Schulz Reviewed-by: Eike Ziller --- src/plugins/texteditor/generichighlighter/highlightdefinition.cpp | 5 +++++ src/plugins/texteditor/generichighlighter/highlightdefinition.h | 2 ++ .../texteditor/generichighlighter/highlightdefinitionhandler.cpp | 2 +- src/plugins/texteditor/plaintexteditor.cpp | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/texteditor/generichighlighter/highlightdefinition.cpp b/src/plugins/texteditor/generichighlighter/highlightdefinition.cpp index 043e2c0eed..744744a71d 100644 --- a/src/plugins/texteditor/generichighlighter/highlightdefinition.cpp +++ b/src/plugins/texteditor/generichighlighter/highlightdefinition.cpp @@ -55,6 +55,11 @@ HighlightDefinition::HighlightDefinition() : HighlightDefinition::~HighlightDefinition() {} +bool HighlightDefinition::isValid() const +{ + return !m_initialContext.isEmpty(); +} + template QSharedPointer HighlightDefinition:: GenericHelper::create(const QString &name, Container &container) diff --git a/src/plugins/texteditor/generichighlighter/highlightdefinition.h b/src/plugins/texteditor/generichighlighter/highlightdefinition.h index 029eaa7e5b..b178a2e476 100644 --- a/src/plugins/texteditor/generichighlighter/highlightdefinition.h +++ b/src/plugins/texteditor/generichighlighter/highlightdefinition.h @@ -51,6 +51,8 @@ public: HighlightDefinition(); ~HighlightDefinition(); + bool isValid() const; + QSharedPointer createKeywordList(const QString &list); QSharedPointer keywordList(const QString &list); diff --git a/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp b/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp index cc123bcf20..a259132291 100644 --- a/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp +++ b/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp @@ -449,7 +449,7 @@ void HighlightDefinitionHandler::processIncludeRules(const QSharedPointer &externalDefinition = Manager::instance()->definition(id); - if (externalDefinition.isNull()) + if (externalDefinition.isNull() || !externalDefinition->isValid()) continue; sourceContext = externalDefinition->initialContext(); diff --git a/src/plugins/texteditor/plaintexteditor.cpp b/src/plugins/texteditor/plaintexteditor.cpp index d1abadb607..90a30a2381 100644 --- a/src/plugins/texteditor/plaintexteditor.cpp +++ b/src/plugins/texteditor/plaintexteditor.cpp @@ -180,7 +180,7 @@ void PlainTextEditorWidget::configure(const Core::MimeType &mimeType) m_isMissingSyntaxDefinition = false; const QSharedPointer &definition = Manager::instance()->definition(definitionId); - if (!definition.isNull()) { + if (!definition.isNull() && definition->isValid()) { highlighter->setDefaultContext(definition->initialContext()); m_commentDefinition.setAfterWhiteSpaces(definition->isCommentAfterWhiteSpaces()); -- cgit v1.2.1 From 20efc0a6f684121f6a9faca555d82b65020af0a0 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Fri, 30 Mar 2012 11:40:31 +0200 Subject: Fix reloading removing all BaseTextMarks It was already broken in 2.4. Task-number: QTCREATORBUG-7110 Change-Id: I24fae889c67ba5436548b7534d7257b6680a8c81 Reviewed-by: Eike Ziller --- src/plugins/texteditor/basetextdocument.cpp | 14 ++++-- src/plugins/texteditor/basetextdocumentlayout.cpp | 61 +++++++++++++++++++---- src/plugins/texteditor/basetextdocumentlayout.h | 11 +++- src/plugins/texteditor/basetextmark.cpp | 50 ++----------------- src/plugins/texteditor/basetextmark.h | 5 -- src/plugins/texteditor/itextmark.cpp | 21 +++++++- src/plugins/texteditor/itextmark.h | 12 ++++- 7 files changed, 105 insertions(+), 69 deletions(-) (limited to 'src') diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp index 99b81191cc..6bf18d8e75 100644 --- a/src/plugins/texteditor/basetextdocument.cpp +++ b/src/plugins/texteditor/basetextdocument.cpp @@ -378,13 +378,17 @@ bool BaseTextDocument::reload(QString *errorString) emit aboutToReload(); BaseTextDocumentLayout *documentLayout = qobject_cast(d->m_document->documentLayout()); + TextMarks marks; if (documentLayout) - documentLayout->documentClosing(); // removes text marks non-permanently + marks = documentLayout->documentClosing(); // removes text marks non-permanently - if (!open(errorString, d->m_fileName, d->m_fileName)) - return false; - emit reloaded(); - return true; + bool success = open(errorString, d->m_fileName, d->m_fileName); + + if (documentLayout) + documentLayout->documentReloaded(marks); // readds text marks + if (success) + emit reloaded(); + return success; } bool BaseTextDocument::reload(QString *errorString, ReloadFlag flag, ChangeType type) diff --git a/src/plugins/texteditor/basetextdocumentlayout.cpp b/src/plugins/texteditor/basetextdocumentlayout.cpp index 66ac014c9b..5378421834 100644 --- a/src/plugins/texteditor/basetextdocumentlayout.cpp +++ b/src/plugins/texteditor/basetextdocumentlayout.cpp @@ -53,6 +53,7 @@ public: void removeMark(ITextMark *mark); void updateMark(ITextMark *mark); + void removeMarkFromMarksCache(TextEditor::ITextMark *mark); private: double recalculateMaxMarkWidthFactor() const; @@ -72,6 +73,8 @@ DocumentMarker::~DocumentMarker() bool DocumentMarker::addMark(TextEditor::ITextMark *mark) { + if (mark->markableInterface()) + return false; QTC_ASSERT(mark->lineNumber() >= 1, return false); int blockNumber = mark->lineNumber() - 1; BaseTextDocumentLayout *documentLayout = @@ -90,6 +93,7 @@ bool DocumentMarker::addMark(TextEditor::ITextMark *mark) documentLayout->maxMarkWidthFactor = qMax(mark->widthFactor(), documentLayout->maxMarkWidthFactor); documentLayout->requestUpdate(); + mark->setMarkableInterface(this); return true; } return false; @@ -116,26 +120,38 @@ TextEditor::TextMarks DocumentMarker::marksAt(int line) const return TextMarks(); } +void DocumentMarker::removeMarkFromMarksCache(TextEditor::ITextMark *mark) +{ + BaseTextDocumentLayout *documentLayout = + qobject_cast(document->documentLayout()); + QTC_ASSERT(documentLayout, return) + bool needUpdate = m_marksCache.removeOne(mark); + if (m_marksCache.isEmpty()) { + documentLayout->hasMarks = false; + needUpdate = true; + } + + if (needUpdate) { + documentLayout->maxMarkWidthFactor = recalculateMaxMarkWidthFactor(); + updateMark(0); + } +} + void DocumentMarker::removeMark(TextEditor::ITextMark *mark) { BaseTextDocumentLayout *documentLayout = qobject_cast(document->documentLayout()); QTC_ASSERT(documentLayout, return) - bool needUpdate = false; QTextBlock block = document->begin(); while (block.isValid()) { if (TextBlockUserData *data = static_cast(block.userData())) { - needUpdate |= data->removeMark(mark); + data->removeMark(mark); } block = block.next(); } - m_marksCache.removeAll(mark); - - if (needUpdate) { - documentLayout->maxMarkWidthFactor = recalculateMaxMarkWidthFactor(); - updateMark(0); - } + removeMarkFromMarksCache(mark); + mark->setMarkableInterface(0); } void DocumentMarker::updateMark(ITextMark *mark) @@ -159,6 +175,10 @@ TextBlockUserData::~TextBlockUserData() TextMarks marks = m_marks; m_marks.clear(); foreach (ITextMark *mrk, marks) { + TextEditor::Internal::DocumentMarker *documentMarker + = static_cast(mrk->markableInterface()); + documentMarker->removeMarkFromMarksCache(mrk); + mrk->setMarkableInterface(0); mrk->removedFromEditor(); } @@ -703,16 +723,37 @@ QSizeF BaseTextDocumentLayout::documentSize() const return size; } -void BaseTextDocumentLayout::documentClosing() +TextMarks BaseTextDocumentLayout::documentClosing() { + TextMarks marks; QTextBlock block = document()->begin(); while (block.isValid()) { if (TextBlockUserData *data = static_cast(block.userData())) - data->documentClosing(); + marks.append(data->documentClosing()); block = block.next(); } + return marks; } +void BaseTextDocumentLayout::documentReloaded(TextMarks marks) +{ + foreach (ITextMark *mark, marks) { + int blockNumber = mark->lineNumber() - 1; + QTextBlock block = document()->findBlockByNumber(blockNumber); + if (block.isValid()) { + TextBlockUserData *userData = BaseTextDocumentLayout::userData(block); + userData->addMark(mark); + mark->setMarkableInterface(m_documentMarker); + mark->updateBlock(block); + } else { + TextEditor::Internal::DocumentMarker *documentMarker + = static_cast(m_documentMarker); + documentMarker->removeMarkFromMarksCache(mark); + mark->removedFromEditor(); + } + } + requestUpdate(); +} void BaseTextDocumentLayout::updateMarksLineNumber() { diff --git a/src/plugins/texteditor/basetextdocumentlayout.h b/src/plugins/texteditor/basetextdocumentlayout.h index 4f052a93b3..bed5b1863f 100644 --- a/src/plugins/texteditor/basetextdocumentlayout.h +++ b/src/plugins/texteditor/basetextdocumentlayout.h @@ -81,7 +81,13 @@ public: void addMark(ITextMark *mark); inline bool removeMark(ITextMark *mark) { return m_marks.removeAll(mark); } - inline void documentClosing() { m_marks.clear(); } + inline TextMarks documentClosing() { + TextMarks marks = m_marks; + foreach (ITextMark *mrk, m_marks) + mrk->setMarkableInterface(0); + m_marks.clear(); + return marks; + } inline void setFolded(bool b) { m_folded = b; } inline bool folded() const { return m_folded; } @@ -214,7 +220,8 @@ public: QSizeF documentSize() const; - void documentClosing(); + TextMarks documentClosing(); + void documentReloaded(TextMarks marks); void updateMarksLineNumber(); void updateMarksBlock(const QTextBlock &block); }; diff --git a/src/plugins/texteditor/basetextmark.cpp b/src/plugins/texteditor/basetextmark.cpp index 9737314651..3c68e36e28 100644 --- a/src/plugins/texteditor/basetextmark.cpp +++ b/src/plugins/texteditor/basetextmark.cpp @@ -55,15 +55,9 @@ void BaseTextMarkRegistry::add(BaseTextMark *mark) Core::EditorManager *em = Core::EditorManager::instance(); foreach (Core::IEditor *editor, em->editorsForFileName(mark->fileName())) { if (ITextEditor *textEditor = qobject_cast(editor)) { - if (mark->m_markableInterface == 0) { // We aren't added to something - ITextMarkable *markableInterface = textEditor->markableInterface(); - if (markableInterface->addMark(mark)) { - mark->m_markableInterface = markableInterface; - // Handle reload of text documents, readding the mark as necessary - connect(textEditor->document(), SIGNAL(reloaded()), - this, SLOT(documentReloaded()), Qt::UniqueConnection); - break; - } + ITextMarkable *markableInterface = textEditor->markableInterface(); + if (markableInterface->addMark(mark)) { + break; } } } @@ -82,34 +76,9 @@ void BaseTextMarkRegistry::editorOpened(Core::IEditor *editor) if (!m_marks.contains(Utils::FileName::fromString(editor->document()->fileName()))) return; - // Handle reload of text documents, readding the mark as necessary - connect(textEditor->document(), SIGNAL(reloaded()), - this, SLOT(documentReloaded()), Qt::UniqueConnection); - foreach (BaseTextMark *mark, m_marks.value(Utils::FileName::fromString(editor->document()->fileName()))) { - if (mark->m_markableInterface == 0) { // We aren't added to something - ITextMarkable *markableInterface = textEditor->markableInterface(); - if (markableInterface->addMark(mark)) - mark->m_markableInterface = markableInterface; - } - } -} - -void BaseTextMarkRegistry::documentReloaded() -{ - BaseTextDocument *doc = qobject_cast(sender()); - if (!doc) - return; - - if (!m_marks.contains(Utils::FileName::fromString(doc->fileName()))) - return; - - foreach (BaseTextMark *mark, m_marks.value(Utils::FileName::fromString(doc->fileName()))) { - if (mark->m_markableInterface) - return; - ITextMarkable *markableInterface = doc->documentMarker(); - if (markableInterface->addMark(mark)) - mark->m_markableInterface = markableInterface; + ITextMarkable *markableInterface = textEditor->markableInterface(); + markableInterface->addMark(mark); } } @@ -122,14 +91,5 @@ BaseTextMark::BaseTextMark(const QString &fileName, int lineNumber) BaseTextMark::~BaseTextMark() { // oha we are deleted - if (m_markableInterface) - m_markableInterface.data()->removeMark(this); - m_markableInterface.clear(); Internal::TextEditorPlugin::instance()->baseTextMarkRegistry()->remove(this); } - -void BaseTextMark::updateMarker() -{ - if (m_markableInterface) - m_markableInterface.data()->updateMark(this); -} diff --git a/src/plugins/texteditor/basetextmark.h b/src/plugins/texteditor/basetextmark.h index 8426abcf9e..064b84d0c3 100644 --- a/src/plugins/texteditor/basetextmark.h +++ b/src/plugins/texteditor/basetextmark.h @@ -61,14 +61,10 @@ public: BaseTextMark(const QString &fileName, int lineNumber); virtual ~BaseTextMark(); - // call this if the icon has changed. - void updateMarker(); - // access to internal data QString fileName() const { return m_fileName; } private: - QWeakPointer m_markableInterface; QString m_fileName; }; @@ -83,7 +79,6 @@ public: void remove(BaseTextMark *mark); private slots: void editorOpened(Core::IEditor *editor); - void documentReloaded(); private: QHash > m_marks; }; diff --git a/src/plugins/texteditor/itextmark.cpp b/src/plugins/texteditor/itextmark.cpp index a999b6367e..bf7030ce07 100644 --- a/src/plugins/texteditor/itextmark.cpp +++ b/src/plugins/texteditor/itextmark.cpp @@ -36,7 +36,9 @@ using namespace TextEditor; ITextMark::~ITextMark() { - + if (m_markableInterface) + m_markableInterface->removeMark(this); + m_markableInterface = 0; } int ITextMark::lineNumber() const @@ -65,6 +67,12 @@ void ITextMark::setIcon(const QIcon &icon) m_icon = icon; } +void ITextMark::updateMarker() +{ + if (m_markableInterface) + m_markableInterface->updateMark(this); +} + void ITextMark::setPriority(Priority priority) { m_priority = priority; @@ -92,3 +100,14 @@ bool ITextMark::clickable() const void ITextMark::clicked() {} + +ITextMarkable *ITextMark::markableInterface() const +{ + return m_markableInterface; +} + +void ITextMark::setMarkableInterface(ITextMarkable *markableInterface) +{ + m_markableInterface = markableInterface; +} + diff --git a/src/plugins/texteditor/itextmark.h b/src/plugins/texteditor/itextmark.h index 48be8b0992..19c8f4750b 100644 --- a/src/plugins/texteditor/itextmark.h +++ b/src/plugins/texteditor/itextmark.h @@ -50,11 +50,16 @@ QT_END_NAMESPACE namespace TextEditor { class ITextEditor; +class ITextMarkable; class TEXTEDITOR_EXPORT ITextMark { public: - ITextMark(int line) : m_lineNumber(line), m_priority(NormalPriority) {} + ITextMark(int line) + : m_markableInterface(0), + m_lineNumber(line), + m_priority(NormalPriority) + {} virtual ~ITextMark(); // determine order on markers on the same line. @@ -71,6 +76,8 @@ public: virtual void updateBlock(const QTextBlock &block); virtual void removedFromEditor(); void setIcon(const QIcon &icon); + // call this if the icon has changed. + void updateMarker(); Priority priority() const; void setPriority(Priority prioriy); virtual bool visible() const; @@ -78,7 +85,10 @@ public: virtual bool clickable() const; virtual void clicked(); + ITextMarkable *markableInterface() const; + void setMarkableInterface(ITextMarkable *markableInterface); private: + ITextMarkable *m_markableInterface; int m_lineNumber; QIcon m_icon; Priority m_priority; -- cgit v1.2.1 From f1c299a85e08c5ce16fc8dad371a11115687edf0 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 5 Apr 2012 06:32:36 +0300 Subject: Qbs: Allow provider specification for plugins Change-Id: I2016da500a9e81d8b2065c4c1c26a15d59c15abf Reviewed-by: Joerg Bornemann --- src/plugins/QtcPlugin.qbs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/QtcPlugin.qbs b/src/plugins/QtcPlugin.qbs index e34a7bcd54..da48870f3b 100644 --- a/src/plugins/QtcPlugin.qbs +++ b/src/plugins/QtcPlugin.qbs @@ -3,7 +3,8 @@ import qbs.fileinfo 1.0 as FileInfo Product { type: ["dynamiclibrary", "pluginSpec"] - destination: "lib/qtcreator/plugins/Nokia" + property string provider: 'Nokia' + destination: "lib/qtcreator/plugins/" + provider targetName: { // see PluginSpecPrivate::loadLibrary() if (qbs.debugInformation) { -- cgit v1.2.1 From 10438d2e9d74fe5ad38f2ccbaf1fbbe8316b4061 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Mon, 12 Mar 2012 16:56:25 +0100 Subject: BaseTextMark: Support renaming files Change-Id: I8d712f76fca5d8f5ecad70f1485228e21c00648d Reviewed-by: Eike Ziller --- src/plugins/bookmarks/bookmark.cpp | 10 +++++ src/plugins/bookmarks/bookmark.h | 3 +- src/plugins/coreplugin/documentmanager.cpp | 13 ++++++ src/plugins/coreplugin/documentmanager.h | 5 +++ src/plugins/coreplugin/idocument.h | 1 + src/plugins/debugger/breakhandler.cpp | 8 ++++ src/plugins/debugger/breakhandler.h | 1 + src/plugins/debugger/breakpointmarker.cpp | 6 +++ src/plugins/debugger/breakpointmarker.h | 1 + src/plugins/designer/formwindowfile.cpp | 4 ++ src/plugins/imageviewer/imageviewerfile.cpp | 2 + src/plugins/projectexplorer/taskhub.cpp | 12 ++++++ src/plugins/projectexplorer/taskhub.h | 2 + src/plugins/projectexplorer/taskmodel.cpp | 10 +++++ src/plugins/projectexplorer/taskmodel.h | 1 + src/plugins/projectexplorer/taskwindow.cpp | 8 ++++ src/plugins/projectexplorer/taskwindow.h | 1 + src/plugins/resourceeditor/resourceeditorw.cpp | 2 + src/plugins/texteditor/basetextdocument.cpp | 5 ++- src/plugins/texteditor/basetextmark.cpp | 56 +++++++++++++++++++++++++- src/plugins/texteditor/basetextmark.h | 8 +++- src/plugins/texteditor/itextmark.h | 1 + 22 files changed, 155 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/bookmarks/bookmark.cpp b/src/plugins/bookmarks/bookmark.cpp index 4de678563d..45fb4bdee3 100644 --- a/src/plugins/bookmarks/bookmark.cpp +++ b/src/plugins/bookmarks/bookmark.cpp @@ -70,6 +70,16 @@ void Bookmark::updateBlock(const QTextBlock &block) } } +void Bookmark::updateFileName(const QString &fileName) +{ + m_fileName = fileName; + QFileInfo fi(fileName); + m_onlyFile = fi.fileName(); + m_path = fi.path(); + m_manager->updateBookmark(this); + BaseTextMark::updateFileName(fileName); +} + QString Bookmark::lineText() const { return m_lineText; diff --git a/src/plugins/bookmarks/bookmark.h b/src/plugins/bookmarks/bookmark.h index 62d55f7d1b..f26a66920f 100644 --- a/src/plugins/bookmarks/bookmark.h +++ b/src/plugins/bookmarks/bookmark.h @@ -54,6 +54,7 @@ public: void updateLineNumber(int lineNumber); void updateBlock(const QTextBlock &block); + void updateFileName(const QString &fileName); void removedFromEditor(); QString filePath() const; @@ -63,7 +64,7 @@ public: private: BookmarkManager *m_manager; - const QString m_fileName; + QString m_fileName; QString m_onlyFile; QString m_path; QString m_lineText; diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index 878c2fb612..9828859f9f 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -294,6 +294,7 @@ void DocumentManager::addDocuments(const QList &documents, bool add foreach (IDocument *document, documents) { if (document && !d->m_documentsWithoutWatch.contains(document)) { connect(document, SIGNAL(destroyed(QObject*)), m_instance, SLOT(documentDestroyed(QObject*))); + connect(document, SIGNAL(fileNameChanged(QString,QString)), m_instance, SLOT(fileNameChanged(QString, QString))); d->m_documentsWithoutWatch.append(document); } } @@ -304,6 +305,7 @@ void DocumentManager::addDocuments(const QList &documents, bool add if (document && !d->m_documentsWithWatch.contains(document)) { connect(document, SIGNAL(changed()), m_instance, SLOT(checkForNewFileName())); connect(document, SIGNAL(destroyed(QObject*)), m_instance, SLOT(documentDestroyed(QObject*))); + connect(document, SIGNAL(fileNameChanged(QString,QString)), m_instance, SLOT(fileNameChanged(QString, QString))); addFileInfo(document); } } @@ -398,7 +400,18 @@ void DocumentManager::renamedFile(const QString &from, const QString &to) addFileInfo(document); d->m_blockedIDocument = 0; } + emit m_instance->allDocumentsRenamed(from, to); } + +void DocumentManager::fileNameChanged(const QString &oldName, const QString &newName) +{ + IDocument *doc = qobject_cast(sender()); + QTC_ASSERT(doc, return); + if (doc == d->m_blockedIDocument) + return; + emit m_instance->documentRenamed(doc, oldName, newName); +} + /*! \fn bool DocumentManager::addFile(IDocument *document, bool addWatcher) diff --git a/src/plugins/coreplugin/documentmanager.h b/src/plugins/coreplugin/documentmanager.h index 7f59e50ecd..23451720e2 100644 --- a/src/plugins/coreplugin/documentmanager.h +++ b/src/plugins/coreplugin/documentmanager.h @@ -148,9 +148,14 @@ signals: /* Used to notify e.g. the code model to update the given files. Does *not* lead to any editors to reload or any other editor manager actions. */ void filesChangedInternally(const QStringList &files); + /// emitted if all documents changed their name e.g. due to the file changing on disk + void allDocumentsRenamed(const QString &from, const QString &to); + /// emitted if one document changed its name e.g. due to save as + void documentRenamed(Core::IDocument *document, const QString &from, const QString &to); private slots: void documentDestroyed(QObject *obj); + void fileNameChanged(const QString &oldName, const QString &newName); void checkForNewFileName(); void checkForReload(); void changedFile(const QString &file); diff --git a/src/plugins/coreplugin/idocument.h b/src/plugins/coreplugin/idocument.h index 8a2716d398..f3048276b1 100644 --- a/src/plugins/coreplugin/idocument.h +++ b/src/plugins/coreplugin/idocument.h @@ -116,6 +116,7 @@ signals: void aboutToReload(); void reloaded(); + void fileNameChanged(const QString &oldName, const QString &newName); private: QString m_autoSaveName; diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 6e892b54b0..3ea1664955 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -1223,6 +1223,14 @@ void BreakHandler::gotoLocation(BreakpointModelId id) const } } +void BreakHandler::updateFileNameFromMarker(BreakpointModelId id, const QString &fileName) +{ + Iterator it = m_storage.find(id); + BREAK_ASSERT(it != m_storage.end(), return); + it->data.fileName = fileName; + emit layoutChanged(); +} + void BreakHandler::updateLineNumberFromMarker(BreakpointModelId id, int lineNumber) { Iterator it = m_storage.find(id); diff --git a/src/plugins/debugger/breakhandler.h b/src/plugins/debugger/breakhandler.h index 04475bc80d..d212b6d9ab 100644 --- a/src/plugins/debugger/breakhandler.h +++ b/src/plugins/debugger/breakhandler.h @@ -134,6 +134,7 @@ public: BreakpointState state(BreakpointModelId id) const; bool isEnabled(BreakpointModelId id) const; void setEnabled(BreakpointModelId id, bool on); + void updateFileNameFromMarker(BreakpointModelId id, const QString &fileName); void updateLineNumberFromMarker(BreakpointModelId id, int lineNumber); void setMarkerFileAndLine(BreakpointModelId id, const QString &fileName, int lineNumber); diff --git a/src/plugins/debugger/breakpointmarker.cpp b/src/plugins/debugger/breakpointmarker.cpp index 214184f9a6..6cac5a37c2 100644 --- a/src/plugins/debugger/breakpointmarker.cpp +++ b/src/plugins/debugger/breakpointmarker.cpp @@ -71,6 +71,12 @@ void BreakpointMarker::updateLineNumber(int lineNumber) breakHandler()->updateLineNumberFromMarker(m_id, lineNumber); } +void BreakpointMarker::updateFileName(const QString &fileName) +{ + BaseTextMark::updateFileName(fileName); + breakHandler()->updateFileNameFromMarker(m_id, fileName); +} + } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/breakpointmarker.h b/src/plugins/debugger/breakpointmarker.h index 4101e7414d..432f59b3cd 100644 --- a/src/plugins/debugger/breakpointmarker.h +++ b/src/plugins/debugger/breakpointmarker.h @@ -48,6 +48,7 @@ public: ~BreakpointMarker(); void removedFromEditor(); void updateLineNumber(int lineNumber); + void updateFileName(const QString &fileName); private: BreakpointModelId m_id; diff --git a/src/plugins/designer/formwindowfile.cpp b/src/plugins/designer/formwindowfile.cpp index 0b05e675ed..eea63511e8 100644 --- a/src/plugins/designer/formwindowfile.cpp +++ b/src/plugins/designer/formwindowfile.cpp @@ -104,9 +104,11 @@ bool FormWindowFile::save(QString *errorString, const QString &name, bool autoSa return false; } + const QString oldFileName = m_fileName; m_fileName = fi.absoluteFilePath(); emit setDisplayName(fi.fileName()); m_formWindow->setDirty(false); + emit fileNameChanged(oldFileName, m_fileName); emit changed(); emit saved(); @@ -117,8 +119,10 @@ void FormWindowFile::rename(const QString &newName) { m_formWindow->setFileName(newName); QFileInfo fi(newName); + const QString oldFileName = m_fileName; m_fileName = fi.absoluteFilePath(); emit setDisplayName(fi.fileName()); + emit fileNameChanged(oldFileName, m_fileName); emit changed(); } diff --git a/src/plugins/imageviewer/imageviewerfile.cpp b/src/plugins/imageviewer/imageviewerfile.cpp index c332af750f..d54cbdce6c 100644 --- a/src/plugins/imageviewer/imageviewerfile.cpp +++ b/src/plugins/imageviewer/imageviewerfile.cpp @@ -97,8 +97,10 @@ bool ImageViewerFile::save(QString *errorString, const QString &fileName, bool a void ImageViewerFile::rename(const QString &newName) { + const QString oldFilename = d->fileName; d->fileName = newName; d->editor->setDisplayName(QFileInfo(d->fileName).fileName()); + emit fileNameChanged(oldFilename, newName); emit changed(); } diff --git a/src/plugins/projectexplorer/taskhub.cpp b/src/plugins/projectexplorer/taskhub.cpp index a05d9dc1fa..1223b46b20 100644 --- a/src/plugins/projectexplorer/taskhub.cpp +++ b/src/plugins/projectexplorer/taskhub.cpp @@ -48,6 +48,7 @@ public: bool clickable() const; void clicked(); + void updateFileName(const QString &fileName); void updateLineNumber(int lineNumber); void removedFromEditor(); bool visible() const; @@ -62,6 +63,12 @@ void TaskMark::updateLineNumber(int lineNumber) BaseTextMark::updateLineNumber(lineNumber); } +void TaskMark::updateFileName(const QString &fileName) +{ + ProjectExplorerPlugin::instance()->taskHub()->updateTaskFileName(m_id, fileName); + BaseTextMark::updateFileName(fileName); +} + void TaskMark::removedFromEditor() { ProjectExplorerPlugin::instance()->taskHub()->updateTaskLineNumber(m_id, -1); @@ -122,6 +129,11 @@ void TaskHub::removeTask(const Task &task) emit taskRemoved(task); } +void TaskHub::updateTaskFileName(unsigned int id, const QString &fileName) +{ + emit taskFileNameUpdated(id, fileName); +} + void TaskHub::updateTaskLineNumber(unsigned int id, int line) { emit taskLineNumberUpdated(id, line); diff --git a/src/plugins/projectexplorer/taskhub.h b/src/plugins/projectexplorer/taskhub.h index 6f92c3dd5e..e48d3f507c 100644 --- a/src/plugins/projectexplorer/taskhub.h +++ b/src/plugins/projectexplorer/taskhub.h @@ -52,6 +52,7 @@ public: void addTask(Task task); void clearTasks(const Core::Id &categoryId = Core::Id()); void removeTask(const Task &task); + void updateTaskFileName(unsigned int id, const QString &fileName); void updateTaskLineNumber(unsigned int id, int line); void taskMarkClicked(unsigned int id); void setCategoryVisibility(const Core::Id &categoryId, bool visible); @@ -65,6 +66,7 @@ signals: void taskAdded(const ProjectExplorer::Task &task); void taskRemoved(const ProjectExplorer::Task &task); void tasksCleared(const Core::Id &categoryId); + void taskFileNameUpdated(unsigned int id, const QString &fileName); void taskLineNumberUpdated(unsigned int id, int line); void categoryVisibilityChanged(const Core::Id &categoryId, bool visible); void popupRequested(bool withFocus); diff --git a/src/plugins/projectexplorer/taskmodel.cpp b/src/plugins/projectexplorer/taskmodel.cpp index edf903ef44..94f2307f9f 100644 --- a/src/plugins/projectexplorer/taskmodel.cpp +++ b/src/plugins/projectexplorer/taskmodel.cpp @@ -156,6 +156,16 @@ int TaskModel::rowForId(unsigned int id) return it - m_tasks.constBegin(); } +void TaskModel::updateTaskFileName(unsigned int id, const QString &fileName) +{ + int i = rowForId(id); + QTC_ASSERT(i != -1, return) + if (m_tasks.at(i).taskId == id) { + m_tasks[i].file = Utils::FileName::fromString(fileName); + emit dataChanged(index(i, 0), index(i, 0)); + } +} + void TaskModel::updateTaskLineNumber(unsigned int id, int line) { int i = rowForId(id); diff --git a/src/plugins/projectexplorer/taskmodel.h b/src/plugins/projectexplorer/taskmodel.h index 017e489b6e..98e857af75 100644 --- a/src/plugins/projectexplorer/taskmodel.h +++ b/src/plugins/projectexplorer/taskmodel.h @@ -62,6 +62,7 @@ public: void addTask(const Task &task); void removeTask(const Task &task); void clearTasks(const Core::Id &categoryId = Core::Id()); + void updateTaskFileName(unsigned int id, const QString &fileName); void updateTaskLineNumber(unsigned int id, int line); int sizeOfFile(const QFont &font); diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index 0b2e981e95..3858c2661e 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -299,6 +299,8 @@ TaskWindow::TaskWindow(TaskHub *taskhub) : d(new TaskWindowPrivate) this, SLOT(removeTask(ProjectExplorer::Task))); connect(d->m_taskHub, SIGNAL(taskLineNumberUpdated(uint,int)), this, SLOT(updatedTaskLineNumber(uint,int))); + connect(d->m_taskHub, SIGNAL(taskFileNameUpdated(uint,QString)), + this, SLOT(updatedTaskFileName(uint,QString))); connect(d->m_taskHub, SIGNAL(tasksCleared(Core::Id)), this, SLOT(clearTasks(Core::Id))); connect(d->m_taskHub, SIGNAL(categoryVisibilityChanged(Core::Id,bool)), @@ -385,6 +387,12 @@ void TaskWindow::removeTask(const Task &task) navigateStateChanged(); } +void TaskWindow::updatedTaskFileName(unsigned int id, const QString &fileName) +{ + d->m_model->updateTaskFileName(id, fileName); + emit tasksChanged(); +} + void TaskWindow::updatedTaskLineNumber(unsigned int id, int line) { d->m_model->updateTaskLineNumber(id, line); diff --git a/src/plugins/projectexplorer/taskwindow.h b/src/plugins/projectexplorer/taskwindow.h index 8a41bf9b1f..a83789b5db 100644 --- a/src/plugins/projectexplorer/taskwindow.h +++ b/src/plugins/projectexplorer/taskwindow.h @@ -89,6 +89,7 @@ private slots: void addCategory(const Core::Id &categoryId, const QString &displayName, bool visible); void addTask(const ProjectExplorer::Task &task); void removeTask(const ProjectExplorer::Task &task); + void updatedTaskFileName(unsigned int id, const QString &fileName); void updatedTaskLineNumber(unsigned int id, int line); void showTask(unsigned int id); void clearTasks(const Core::Id &categoryId); diff --git a/src/plugins/resourceeditor/resourceeditorw.cpp b/src/plugins/resourceeditor/resourceeditorw.cpp index 150a4a3ce8..33ded8d76b 100644 --- a/src/plugins/resourceeditor/resourceeditorw.cpp +++ b/src/plugins/resourceeditor/resourceeditorw.cpp @@ -194,7 +194,9 @@ bool ResourceEditorDocument::save(QString *errorString, const QString &name, boo void ResourceEditorDocument::rename(const QString &newName) { + const QString oldName = m_parent->m_resourceEditor->fileName(); m_parent->m_resourceEditor->setFileName(newName); + emit fileNameChanged(oldName, newName); // TODO Are there other cases where the ressource file name changes? emit changed(); } diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp index 6bf18d8e75..22cb9fcd56 100644 --- a/src/plugins/texteditor/basetextdocument.cpp +++ b/src/plugins/texteditor/basetextdocument.cpp @@ -268,9 +268,10 @@ bool BaseTextDocument::save(QString *errorString, const QString &fileName, bool return true; const QFileInfo fi(fName); + const QString oldFileName = d->m_fileName; d->m_fileName = QDir::cleanPath(fi.absoluteFilePath()); - d->m_document->setModified(false); + emit fileNameChanged(oldFileName, d->m_fileName); emit titleChanged(fi.fileName()); emit changed(); return true; @@ -284,7 +285,9 @@ bool BaseTextDocument::shouldAutoSave() const void BaseTextDocument::rename(const QString &newName) { const QFileInfo fi(newName); + const QString oldFileName = d->m_fileName; d->m_fileName = QDir::cleanPath(fi.absoluteFilePath()); + emit fileNameChanged(oldFileName, d->m_fileName); emit titleChanged(fi.fileName()); emit changed(); } diff --git a/src/plugins/texteditor/basetextmark.cpp b/src/plugins/texteditor/basetextmark.cpp index 3c68e36e28..6f5898a532 100644 --- a/src/plugins/texteditor/basetextmark.cpp +++ b/src/plugins/texteditor/basetextmark.cpp @@ -36,6 +36,7 @@ #include "texteditorplugin.h" #include +#include #include using namespace TextEditor; @@ -47,11 +48,17 @@ BaseTextMarkRegistry::BaseTextMarkRegistry(QObject *parent) Core::EditorManager *em = Core::EditorManager::instance(); connect(em, SIGNAL(editorOpened(Core::IEditor*)), SLOT(editorOpened(Core::IEditor*))); + + Core::DocumentManager *dm = Core::DocumentManager::instance(); + connect(dm, SIGNAL(allDocumentsRenamed(QString,QString)), + this, SLOT(allDocumentsRenamed(QString,QString))); + connect(dm, SIGNAL(documentRenamed(Core::IDocument*,QString,QString)), + this, SLOT(documentRenamed(Core::IDocument*,QString,QString))); } void BaseTextMarkRegistry::add(BaseTextMark *mark) { - m_marks[Utils::FileName::fromString(mark->fileName())].append(mark); + m_marks[Utils::FileName::fromString(mark->fileName())].insert(mark); Core::EditorManager *em = Core::EditorManager::instance(); foreach (Core::IEditor *editor, em->editorsForFileName(mark->fileName())) { if (ITextEditor *textEditor = qobject_cast(editor)) { @@ -65,7 +72,7 @@ void BaseTextMarkRegistry::add(BaseTextMark *mark) void BaseTextMarkRegistry::remove(BaseTextMark *mark) { - m_marks[Utils::FileName::fromString(mark->fileName())].removeOne(mark); + m_marks[Utils::FileName::fromString(mark->fileName())].remove(mark); } void BaseTextMarkRegistry::editorOpened(Core::IEditor *editor) @@ -82,6 +89,46 @@ void BaseTextMarkRegistry::editorOpened(Core::IEditor *editor) } } +void BaseTextMarkRegistry::documentRenamed(Core::IDocument *document, const + QString &oldName, const QString &newName) +{ + TextEditor::BaseTextDocument *baseTextDocument + = qobject_cast(document); + if (!document) + return; + Utils::FileName oldFileName = Utils::FileName::fromString(oldName); + Utils::FileName newFileName = Utils::FileName::fromString(newName); + if (!m_marks.contains(oldFileName)) + return; + + QSet toBeMoved; + foreach (ITextMark *mark, baseTextDocument->documentMarker()->marks()) + if (BaseTextMark *baseTextMark = dynamic_cast(mark)) + toBeMoved.insert(baseTextMark); + + m_marks[oldFileName].subtract(toBeMoved); + m_marks[newFileName].unite(toBeMoved); + + foreach (BaseTextMark *mark, toBeMoved) + mark->updateFileName(newName); +} + +void BaseTextMarkRegistry::allDocumentsRenamed(const QString &oldName, const QString &newName) +{ + Utils::FileName oldFileName = Utils::FileName::fromString(oldName); + Utils::FileName newFileName = Utils::FileName::fromString(newName); + if (!m_marks.contains(oldFileName)) + return; + + QSet oldFileNameMarks = m_marks.value(oldFileName); + + m_marks[newFileName].unite(oldFileNameMarks); + m_marks[oldFileName].clear(); + + foreach (BaseTextMark *mark, oldFileNameMarks) + mark->updateFileName(newName); +} + BaseTextMark::BaseTextMark(const QString &fileName, int lineNumber) : ITextMark(lineNumber), m_fileName(fileName) { @@ -93,3 +140,8 @@ BaseTextMark::~BaseTextMark() // oha we are deleted Internal::TextEditorPlugin::instance()->baseTextMarkRegistry()->remove(this); } + +void BaseTextMark::updateFileName(const QString &fileName) +{ + m_fileName = fileName; +} diff --git a/src/plugins/texteditor/basetextmark.h b/src/plugins/texteditor/basetextmark.h index 064b84d0c3..1b31724f2f 100644 --- a/src/plugins/texteditor/basetextmark.h +++ b/src/plugins/texteditor/basetextmark.h @@ -40,6 +40,7 @@ #include #include +#include QT_BEGIN_NAMESPACE class QTextBlock; @@ -61,6 +62,9 @@ public: BaseTextMark(const QString &fileName, int lineNumber); virtual ~BaseTextMark(); + /// called if the filename of the document changed + virtual void updateFileName(const QString &fileName); + // access to internal data QString fileName() const { return m_fileName; } @@ -79,8 +83,10 @@ public: void remove(BaseTextMark *mark); private slots: void editorOpened(Core::IEditor *editor); + void documentRenamed(Core::IDocument *document, const QString &oldName, const QString &newName); + void allDocumentsRenamed(const QString &oldName, const QString &newName); private: - QHash > m_marks; + QHash > m_marks; }; } diff --git a/src/plugins/texteditor/itextmark.h b/src/plugins/texteditor/itextmark.h index 19c8f4750b..79e0ca0131 100644 --- a/src/plugins/texteditor/itextmark.h +++ b/src/plugins/texteditor/itextmark.h @@ -103,6 +103,7 @@ class TEXTEDITOR_EXPORT ITextMarkable : public QObject public: ITextMarkable(QObject *parent = 0) : QObject(parent) {} + virtual TextMarks marks() const = 0; virtual bool addMark(ITextMark *mark) = 0; virtual TextMarks marksAt(int line) const = 0; virtual void removeMark(ITextMark *mark) = 0; -- cgit v1.2.1 From 2aa4b803a636751c9e97bd0c655a0c37bf921622 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 5 Apr 2012 08:51:33 +0200 Subject: Work around uiLanguages crash on Windows with 4.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTCREATORBUG-721 Change-Id: I159c4ef85eba1eda9f3b7e3a001dd6991d578ffe Reviewed-by: Robert Löhning --- src/app/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/app/main.cpp b/src/app/main.cpp index 0fbbc5e1b0..d22cccd51e 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -272,7 +272,8 @@ int main(int argc, char **argv) QTranslator translator; QTranslator qtTranslator; QStringList uiLanguages; -#if QT_VERSION >= 0x040800 +// uiLanguages crashes on Windows with 4.8.0 release builds +#if (QT_VERSION >= 0x040801) || (QT_VERSION >= 0x040800 && !defined(Q_OS_WIN)) uiLanguages = QLocale::system().uiLanguages(); #else uiLanguages << QLocale::system().name(); -- cgit v1.2.1