From kde-core-devel Thu Jul 15 18:08:03 2004 From: Albert Astals Cid Date: Thu, 15 Jul 2004 18:08:03 +0000 To: kde-core-devel Subject: Re: Kcontrol memory leak (patches included) Message-Id: <200407152008.03162.astals11 () terra ! es> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=108991486616423 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_Dgs9ALB8XwBMADZ" --Boundary-00=_Dgs9ALB8XwBMADZ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Following Waldo's recommendations i changed the function to setAboutData(KAboutData *) What do you think about the patches now? I attach the kcmodule changes and three kcontrol modules that i have ported to the new system. Albert A Dimecres 14 Juliol 2004 21:46, Waldo Bastian va escriure: > On Wed July 14 2004 20:17, Albert Astals Cid wrote: > > 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) > > KAboutData is doesn't have a proper copy constructor (unless it was > recently added) so new KAboutData( aboutData ) doesn't exactly work. Why > not change the function from setAboutData(const KAboutData&) to > setAboutData(KAboutData *)? > > Cheers, > Waldo --Boundary-00=_Dgs9ALB8XwBMADZ Content-Type: text/x-diff; charset="iso-8859-1"; name="KCMdiff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="KCMdiff" ? 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 15 Jul 2004 18:01:43 -0000 @@ -23,6 +23,7 @@ #include +#include #include #include #include @@ -37,11 +38,13 @@ { public: KCModulePrivate(): + _about( 0 ), _useRootOnlyMsg( true ), _hasOwnInstance( true ) { } KInstance *_instance; + KAboutData *_about; QString _rootOnlyMsg; bool _useRootOnlyMsg; bool _hasOwnInstance; @@ -90,6 +93,7 @@ { if (d->_hasOwnInstance) delete d->_instance; + delete d->_about; delete d; } @@ -114,6 +118,16 @@ manager->updateWidgetsDefault(); } +const KAboutData *KCModule::aboutData() const +{ + return d->_about; +} + +void KCModule::setAboutData( KAboutData* about ) +{ + delete d->_about; + d->_about = 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 15 Jul 2004 18:01:43 -0000 @@ -174,13 +174,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 + * @return 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( KAboutData* about ); /** * Indicate which buttons will be used. --Boundary-00=_Dgs9ALB8XwBMADZ Content-Type: text/x-diff; charset="iso-8859-1"; name="artsKCMdiff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="artsKCMdiff" ? 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 15 Jul 2004 18:01:12 -0000 @@ -217,6 +217,12 @@ connect(hardware->midiMapper, SIGNAL( textChanged( const QString& ) ), this, SLOT( slotChanged() ) ); + 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"); + 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 15 Jul 2004 18:01:12 -0000 @@ -59,7 +59,6 @@ void defaults(); QString quickHelp() const; - const KAboutData* aboutData() const; private slots: --Boundary-00=_Dgs9ALB8XwBMADZ Content-Type: text/x-diff; charset="iso-8859-1"; name="bellKCM.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="bellKCM.diff" ? bellKCM.diff Index: bell.cpp =================================================================== RCS file: /home/kde/kdebase/kcontrol/bell/bell.cpp,v retrieving revision 1.50 diff -u -r1.50 bell.cpp --- bell.cpp 19 May 2004 12:52:11 -0000 1.50 +++ bell.cpp 15 Jul 2004 18:00:55 -0000 @@ -126,6 +126,17 @@ connect(m_volume, SIGNAL(valueChanged(int)), SLOT(configChanged())); connect(m_pitch, SIGNAL(valueChanged(int)), SLOT(configChanged())); connect(m_duration, SIGNAL(valueChanged(int)), SLOT(configChanged())); + + KAboutData *about = + new KAboutData(I18N_NOOP("kcmbell"), I18N_NOOP("KDE Bell Control Module"), + 0, 0, KAboutData::License_GPL, + I18N_NOOP("(c) 1997 - 2001 Christian Czezatke, Matthias Elter")); + + about->addAuthor("Christian Czezatke", I18N_NOOP("Original author"), "e9025461@student.tuwien.ac.at"); + about->addAuthor("Bernd Wuebben", 0, "wuebben@kde.org"); + about->addAuthor("Matthias Elter", I18N_NOOP("Current maintainer"), "elter@kde.org"); + about->addAuthor("Carsten Pfeiffer", 0, "pfeiffer@kde.org"); + setAboutData(about); load(); } @@ -235,22 +246,6 @@ " a sound file to be played instead of the standard bell."); } -const KAboutData* KBellConfig::aboutData() const -{ - - KAboutData *about = - new KAboutData(I18N_NOOP("kcmbell"), I18N_NOOP("KDE Bell Control Module"), - 0, 0, KAboutData::License_GPL, - I18N_NOOP("(c) 1997 - 2001 Christian Czezatke, Matthias Elter")); - - about->addAuthor("Christian Czezatke", I18N_NOOP("Original author"), "e9025461@student.tuwien.ac.at"); - about->addAuthor("Bernd Wuebben", 0, "wuebben@kde.org"); - about->addAuthor("Matthias Elter", I18N_NOOP("Current maintainer"), "elter@kde.org"); - about->addAuthor("Carsten Pfeiffer", 0, "pfeiffer@kde.org"); - - return about; -} - void KBellConfig::useBell( bool on ) { m_volume->setEnabled( on ); Index: bell.h =================================================================== RCS file: /home/kde/kdebase/kcontrol/bell/bell.h,v retrieving revision 1.20 diff -u -r1.20 bell.h --- bell.h 8 Nov 2003 23:43:50 -0000 1.20 +++ bell.h 15 Jul 2004 18:00:55 -0000 @@ -38,7 +38,6 @@ void save(); void defaults(); QString quickHelp() const; - const KAboutData* aboutData() const; protected slots: void ringBell(); --Boundary-00=_Dgs9ALB8XwBMADZ--