kdevelop patch.

W. Tasin tasin at fhm.edu
Thu Mar 28 11:39:05 UTC 2002


  Harald Fernengel wrote:

>Hi,
>
>>The first one might fix the following leak trapped by valgrind
>>
>
>whoops... sorry, your first patch crashes KDevelop if you open a project, 
>close it and open another one again. The problem is that the QPtrDict "dict" 
>is set to autoDelete, so it deletes all its members -> double deletion crash.
>
>The memory leak occurs because "dict" doesn't get deleted in the destructor, 
>so it never deletes its contents. This patch should fix it:
>
>Index: clogfileview.cpp
>===================================================================
>RCS file: /home/kde/kdevelop/kdevelop/Attic/clogfileview.cpp,v
>retrieving revision 1.28.2.3.2.10.2.5
>diff -u -3 -p -r1.28.2.3.2.10.2.5 clogfileview.cpp
>--- clogfileview.cpp    2002/01/31 00:25:53     1.28.2.3.2.10.2.5
>+++ clogfileview.cpp    2002/03/24 23:23:16
>@@ -64,6 +64,7 @@ CLogFileView::CLogFileView(bool s_path,
> }
>
> CLogFileView::~CLogFileView(){
>+  delete dict;
> }
>
Hi Harry, hi jbb,

please do it - like every deletion should be done, if the pointer lives 
longer than the method (or the object) -

-----
delete dict;
dict=0l;
-----

some reasons for it:
- destructors can be invoked also manually
- deletion of dict-object may be necessary inside another mehtod (e.g. 
by a patch).

I know it seems to be a stylistic question in this case, but it is a 
better way than hunting later some crashes.

... to prevent double or triple deletion !ALWAYS! set those pointers to 
NULL after object deletion.


Ciao

Walter






More information about the KDevelop-devel mailing list