https://bugs.kde.org/show_bug.cgi?id=378909

--- Comment #7 from RJVB <rjvber...@gmail.com> ---
Comment on attachment 105074
  --> https://bugs.kde.org/attachment.cgi?id=105074
clean up VCSDiffPatchSource/PatchReview diff files

diff --git plugins/patchreview/patchreview.cpp
plugins/patchreview/patchreview.cpp
index
06d514945bad42a4f7169bdd7f633db4fed9e859..f222bbb311bc9924592893c81e720a51636dbd63
100644
--- plugins/patchreview/patchreview.cpp
+++ plugins/patchreview/patchreview.cpp
@@ -58,12 +58,12 @@
 #include <sublime/area.h>
 #include <sublime/document.h>
 #include <sublime/view.h>
+#include <vcs/widgets/vcsdiffpatchsources.h>
 #include "patchhighlighter.h"
 #include "patchreviewtoolview.h"
 #include "localpatchsource.h"
 #include "debug.h"

-
 Q_LOGGING_CATEGORY(PLUGIN_PATCHREVIEW, "kdevplatform.plugins.patchreview")

 using namespace KDevelop;
@@ -489,10 +500,18 @@ void PatchReviewPlugin::setPatch( IPatchSource* patch ) {

     if( m_patch ) {
         disconnect( m_patch.data(), &IPatchSource::patchChanged, this,
&PatchReviewPlugin::notifyPatchChanged );
-        if ( qobject_cast<LocalPatchSource*>( m_patch ) ) {
+        if ( qobject_cast<LocalPatchSource*>( m_patch )
+            || qobject_cast<VCSDiffPatchSource*>( m_patch ) ) {
             // make sure we don't leak this
             // TODO: what about other patch sources?
+            IDocument* patchDocument =
ICore::self()->documentController()->documentForUrl( m_patch->file() );
+            if (patchDocument) {
+                // it certainly shouldn't hurt to close the diff document now
instead of at some later point.
+                patchDocument->close(IDocument::Discard);
+            }
             m_patch->deleteLater();
+        } else {
+            qCWarning(PLUGIN_PATCHREVIEW) << "LEAKING" << m_patch <<
m_patch->name() << m_patch->file();
         }
     }
     m_patch = patch;

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to