KDE/kdelibs/kate/completion

Dominik Haumann dhdev at gmx.de
Fri Apr 24 14:28:17 UTC 2009


SVN commit 958730 by dhaumann:

fix crash: on document reload all SmartRanges are deleted.
There are the following ways to work around this:
- use a Notifier/Watcher to keep track of when the range is deleted
  (this is the only way from outside katepart)
- use KateSmartRange::setInternal() on the created SmartRange.
  The KateDocument does not delete SmartRanges marked as interna.
  (only possible from inside katepart)
- use KateSmartRangePtr, which gets automatically 0 when the range
  is deleted. (only possible from inside katepart)

notify developers about this issue:
CCMAIL: kwrite-devel at kde.org
CCMAIL: kdevelop-devel at kdevelop.org


 M  +7 -4      katewordcompletion.cpp  


--- trunk/KDE/kdelibs/kate/completion/katewordcompletion.cpp #958729:958730
@@ -31,6 +31,7 @@
 #include "kateview.h"
 #include "katedocument.h"
 #include "kateglobal.h"
+#include "katesmartrange.h"
 
 #include <ktexteditor/variableinterface.h>
 #include <ktexteditor/smartinterface.h>
@@ -131,16 +132,16 @@
    */
   if (it==AutomaticInvocation) {
       KateView *v = qobject_cast<KateView*> (view);
-    
+
       if (range.columnWidth() >= v->config()->wordCompletionMinimalWordLength())
         saveMatches( view, range );
       else
         m_matches.clear();
-        
+
       // done here...
       return;
   }
-  
+
   // normal case ;)
   saveMatches( view, range );
 }
@@ -218,6 +219,8 @@
     return;
 
   d->liRange = si->newSmartRange();
+  // (dh) guard the smart range to not become a dangling pointer on document reload
+  static_cast<KateSmartRange*>(d->liRange)->setInternal();
 
   KColorScheme colors(QPalette::Active);
   KTextEditor::Attribute::Ptr a = KTextEditor::Attribute::Ptr( new KTextEditor::Attribute() );
@@ -281,7 +284,7 @@
   KTextEditor::CodeCompletionInterface *cci = qobject_cast<KTextEditor::CodeCompletionInterface *>( m_view );
   if(!cci || cci->isCompletionActive())
     return;
-  
+
   m_dWCompletionModel->saveMatches( m_view, r );
 
   kDebug( 13040 ) << "after save matches ...";




More information about the KDevelop-devel mailing list