[Ktutorial-commits] SF.net SVN: ktutorial:[239] trunk/ktutorial/ktutorial-library/src/KTutorial .cp
Status: Alpha
Brought to you by:
danxuliu
|
From: <dan...@us...> - 2010-05-18 15:29:56
|
Revision: 239
http://ktutorial.svn.sourceforge.net/ktutorial/?rev=239&view=rev
Author: danxuliu
Date: 2010-05-18 15:29:49 +0000 (Tue, 18 May 2010)
Log Message:
-----------
Fix memory leak making TutorialKxmlGuiClient a subclass of QObject, so it is automatically destroyed when the KXmlGuiWindow is destroyed.
Modified Paths:
--------------
trunk/ktutorial/ktutorial-library/src/KTutorial.cpp
Modified: trunk/ktutorial/ktutorial-library/src/KTutorial.cpp
===================================================================
--- trunk/ktutorial/ktutorial-library/src/KTutorial.cpp 2010-05-11 03:38:55 UTC (rev 238)
+++ trunk/ktutorial/ktutorial-library/src/KTutorial.cpp 2010-05-18 15:29:49 UTC (rev 239)
@@ -40,9 +40,15 @@
//public:
-class TutorialKXmlGuiClient: public KXMLGUIClient {
+//It inherits from QObject to be automatically destroyed when the parent
+//KXmlGuiWindow is destroyed. It uses the same strategy as
+//KDEPrivate::ToolBarHandler.
+//Usually I do not like multiple inheritance, but it comes very handy here :)
+class TutorialKXmlGuiClient: public QObject, public KXMLGUIClient {
+Q_OBJECT
public:
- TutorialKXmlGuiClient(KXMLGUIClient* parent): KXMLGUIClient(parent) {
+ TutorialKXmlGuiClient(KXmlGuiWindow* parent):
+ QObject(parent), KXMLGUIClient(parent) {
setComponentData(KComponentData("ktutorial"));
setXMLFile("ktutorialui.rc");
}
@@ -112,3 +118,6 @@
void KTutorial::enableTutorialsAction() {
mTutorialsAction->setEnabled(true);
}
+
+#include "moc_KTutorial.cpp"
+#include "KTutorial.moc"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|