| 172 | } |
| 173 | |
| 174 | void ProblemReporterPlugin::documentUrlChanged(IDocument* document, const QUrl& previousUrl) |
| 175 | { |
| 176 | if (!document->textDocument()) |
| 177 | return; |
| 178 | |
| 179 | qCDebug(PLUGIN_PROBLEMREPORTER) << "document URL changed from" << previousUrl.toString() << "to" |
| 180 | << document->url().toString(); |
| 181 | |
| 182 | const IndexedString previousUrlIndexed(previousUrl); |
| 183 | const auto it = m_visualizers.constFind(previousUrlIndexed); |
| 184 | if (it == m_visualizers.cend()) { |
| 185 | qCWarning(PLUGIN_PROBLEMREPORTER) |
| 186 | << "a visualizer for renamed document is missing:" << document->textDocument(); |
| 187 | return; |
| 188 | } |
| 189 | Q_ASSERT(it.value()->document() == document->textDocument()); |
| 190 | |
| 191 | m_reHighlightNeeded.remove(previousUrlIndexed); |
| 192 | |
| 193 | auto* const visualizer = it.value(); |
| 194 | m_visualizers.erase(it); |
| 195 | |
| 196 | const IndexedString currentUrl{document->url()}; |
| 197 | if (m_visualizers.contains(currentUrl)) { |
| 198 | // The renamed document must have been closed already in DocumentControllerPrivate::changeDocumentUrl() |
| 199 | // because of a conflict with another open modified document at its new URL. See a similar comment in |
| 200 | // ProblemReporterPlugin::documentClosed(). Just destroy document's obsolete visualizer here. |
| 201 | delete visualizer; |
| 202 | qCDebug(PLUGIN_PROBLEMREPORTER) << "the renamed document's URL equals another document's URL:" << document; |
| 203 | return; |
| 204 | } |
| 205 | m_visualizers.insert(currentUrl, visualizer); |
| 206 | } |
| 207 | |
| 208 | void ProblemReporterPlugin::documentActivated(KDevelop::IDocument* document) |
| 209 | { |