Double object deletion in KHTMLPart dtor

David Faure dfaure at klaralvdalens-datakonsult.se
Wed Dec 10 13:49:34 GMT 2003


On Tuesday 09 December 2003 17:14, Andras Mantia wrote:
> Dirk Mueller wrote:
> 
> > On Tuesday 09 December 2003 16:42, Andras Mantia wrote:
> >
> >> in the documentation and close Quanta. valgrind reports:
> >
> > can you please rerun with --num-callers=42 so that the backtraces are at
> > least somehow usable?
> 
> I'm not a valgrind guru, so I didn't know about that. Here is the new result
> (as you seen not all of the kdelibs is compiled with debug info,
> but it should be traceable). Looks like the KFind object is already deleted when
> the KHTMLView is destroyed. 
No, when the part is destroyed.

You're deleting the widget (view) before the part, which should be fine.

> Is widget() here a KHTMLView?
Yes.
And when deleting the view before the part, ~QObject (for the view)
deletes the kfind object before khtmlpart deletes it -> double deletion.

Solution (untested):

--- khtmlpart_p.h       16 Nov 2003 21:26:48 -0000      1.49
+++ khtmlpart_p.h       10 Dec 2003 13:49:06 -0000
@@ -420,7 +420,7 @@ public:
   };
   QValueList<StringPortion> m_stringPortions;

-  KFind *m_find;
+  QGuardedPtr<KFind> m_find; // guarded against deletion by parent, which is the KHTMLView
   KFindDialog *m_findDialog;

   struct findState

-- 
David Faure -- faure at kde.org, dfaure at klaralvdalens-datakonsult.se
Qt/KDE/KOffice developer
Klarälvdalens Datakonsult AB, Platform-independent software solutions




More information about the kfm-devel mailing list