[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Kcontrol memory leak (patches included)
From:       Albert Astals Cid <astals11 () terra ! es>
Date:       2004-07-14 18:17:23
Message-ID: 200407142017.23780.astals11 () terra ! es
[Download RAW message or body]

Ok then i attach two patches.

KCMdiff is a patch to kcmodule.cpp and .h to add the functions Frans 
suggested.
artsKCMdiff is a patch to port arts kcontrol module to the new functions.

I think they are fine, but for some strange reason i don't get the about 
option all i get in kcontrol Help is a disabled entry saying "About Current 
Module".

Can someone please test the patches and tell me if they see the personalitzed 
about in arts module or they get "About Current Module" in grey ? (i think my 
kde stable version may be interfering)

Albert.

A Dimecres 14 Juliol 2004 12:54, Waldo Bastian va escriure:
> On Wed July 14 2004 01:35, Albert Astals Cid wrote:
> > Looking again at KCModule i see that
> >
> > /**
> >    * This is generally only called for the KBugReport.
> >    * Override and have it return a pointer to a constant.
> >    *
> >    * @note it is mandatory to implement this function.
> >    *
> >    * @returns the KAboutData for this module
> >    */
> >   virtual const KAboutData *aboutData() const { return 0; }
> >
> > it says you have to override it.
> >
> > To make the code you suggest work, the virtual should be removed
>
> No, it doesn't.
>
> > to ensure
> > kcontrol modules make use of the setAboutData and KCModule's aboutData
> > and not the redefined aboutData,
>
> If a module reimplements aboutData then it needs to take care of the object
> itself, if he uses setAuboutData then the module shouldn't reimplement
> aboutData and everything will be taken care of for him.
>
> > but the BC will be broken (if i undestand
> > http://developer.kde.org/documentation/library/kdeqt/kde3arch/devel-binar
> >yc ompatibility.html correctly) if the virtual is removed.
>
> Yes, so that's no option nor is it needed.
>
> Cheers,
> Waldo

["KCMdiff" (text/x-diff)]

? KCMdiff
Index: kcmodule.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kcmodule.cpp,v
retrieving revision 1.25
diff -u -r1.25 kcmodule.cpp
--- kcmodule.cpp	13 Jul 2004 14:37:47 -0000	1.25
+++ kcmodule.cpp	14 Jul 2004 17:40:09 -0000
@@ -37,11 +37,13 @@
 {
 public:
     KCModulePrivate():
+        _about( 0 ),
         _useRootOnlyMsg( true ),
         _hasOwnInstance( true )
         { }
 
     KInstance *_instance;
+    KAboutData *_about;
     QString _rootOnlyMsg;
     bool _useRootOnlyMsg;
     bool _hasOwnInstance;
@@ -90,6 +92,7 @@
 {
     if (d->_hasOwnInstance)
        delete d->_instance;
+    delete d->_about;
     delete d;
 }
 
@@ -114,6 +117,16 @@
         manager->updateWidgetsDefault();
 }
 
+const KAboutData *KCModule::aboutData() const
+{
+    return d->_about;
+}
+
+void KCModule::setAboutData( const KAboutData& about )
+{
+    delete d->_about;
+    d->_about = new KAboutData(about);
+}
 
 void KCModule::setRootOnlyMsg(const QString& msg)
 {
Index: kcmodule.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kcmodule.h,v
retrieving revision 1.43
diff -u -r1.43 kcmodule.h
--- kcmodule.h	13 Jul 2004 14:37:47 -0000	1.43
+++ kcmodule.h	14 Jul 2004 17:40:10 -0000
@@ -25,9 +25,10 @@
 
 #include <qwidget.h>
 
+#include <kaboutdata.h>
+
 class QStringList;
 
-class KAboutData;
 class KConfigDialogManager;
 class KConfigSkeleton;
 class KCModulePrivate;
@@ -174,13 +175,17 @@
 
   /**
    * This is generally only called for the KBugReport.
-   * Override and have it return a pointer to a constant.
+   * If you override you should  have it return a pointer to a constant.
    *
-   * @note it is mandatory to implement this function.
    *
    * @returns the KAboutData for this module
    */
-  virtual const KAboutData *aboutData() const { return 0; }
+  virtual const KAboutData *aboutData() const;
+  
+  /**
+   * This sets the KAboutData returned by aboutData()
+   */
+   void setAboutData( const KAboutData& about );
 
   /**
    * Indicate which buttons will be used.

["artsKCMdiff" (text/x-diff)]

? artsKCMdiff
Index: arts.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/arts/arts.cpp,v
retrieving revision 1.104
diff -u -r1.104 arts.cpp
--- arts.cpp	8 May 2004 22:13:08 -0000	1.104
+++ arts.cpp	14 Jul 2004 17:40:50 -0000
@@ -217,6 +217,12 @@
 	connect(hardware->midiMapper, SIGNAL( textChanged( const QString& ) ),
 			this, SLOT( slotChanged() ) );
 
+	KAboutData about(I18N_NOOP("kcmarts"),
+                  I18N_NOOP("The Sound Server Control Module"),
+                  0, 0, KAboutData::License_GPL,
+                  I18N_NOOP("(c) 1999 - 2001, Stefan Westerfeld"));
+	about.addAuthor("Stefan Westerfeld",I18N_NOOP("aRts Author") , "stw@kde.org");
+	setAboutData(about);
 }
 
 void KArtsModule::GetSettings( void )
@@ -449,19 +455,6 @@
 		    " an easy way to achieve sound support.");
 }
 
-const KAboutData* KArtsModule::aboutData() const
-{
-   KAboutData *about =
-   new KAboutData(I18N_NOOP("kcmarts"),
-                  I18N_NOOP("The Sound Server Control Module"),
-                  0, 0, KAboutData::License_GPL,
-                  I18N_NOOP("(c) 1999 - 2001, Stefan Westerfeld"));
-
-   about->addAuthor("Stefan Westerfeld",I18N_NOOP("aRts Author") , "stw@kde.org");
-
-   return about;
-}
-
 void KArtsModule::calculateLatency()
 {
 	int latencyInBytes, latencyInMs;
Index: arts.h
===================================================================
RCS file: /home/kde/kdebase/kcontrol/arts/arts.h,v
retrieving revision 1.31
diff -u -r1.31 arts.h
--- arts.h	20 Aug 2003 11:30:39 -0000	1.31
+++ arts.h	14 Jul 2004 17:40:50 -0000
@@ -59,7 +59,6 @@
   void defaults();
 
   QString quickHelp() const;
-  const KAboutData* aboutData() const;
 
 private slots:
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic