--1yeeQ81UyVL57Vl7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Oct 30, 2001 at 06:17:10PM +0100, David Faure wrote: > - I agree with your commented out "delete factory" etc. I've been telling Simon > about those possible leaks too ;). Actually all your factory code could be reduced Hehe ;-) The first one ('delete lib' followed by a commented 'delete factory;?' isn't a leak. The KLibrary object owns the factory, hence it deletes it in its destructor - having a 'delete factory' would result in a double deletion. The second case (if !object->inherits(...) ) is indeed a leak. Well, sort of. Of course the library gets destructed at the end of the application, but you're right, we should do it right then. Holger, is the attached patch okay to commit? About the indenting... :-} Right now it's a mix of spaces, 4 space wide tabs and 8 space wide tabs :-} ... Can we agree on one? (not one space but one indenting style ;-) Other than that: Great work! Looking forward to popupmenu plugins :) Simon --1yeeQ81UyVL57Vl7 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="popup_patch.txt" Index: konq_popupmenu.cc =================================================================== RCS file: /home/kde/kdebase/libkonq/konq_popupmenu.cc,v retrieving revision 1.91 diff -u -p -r1.91 konq_popupmenu.cc --- konq_popupmenu.cc 2001/10/30 18:09:01 1.91 +++ konq_popupmenu.cc 2001/10/31 07:01:06 @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -87,7 +88,7 @@ KonqPopupMenu::KonqPopupMenu( const KFil int id = 0; setFont(KGlobalSettings::menuFont()); - m_pluginList.setAutoDelete( true ); + m_pluginList.setAutoDelete( true ); m_ownActions.setHighlightingEnabled( true ); attrName = QString::fromLatin1( "name" ); @@ -544,50 +545,27 @@ KActionCollection *KonqPopupMenu::action return const_cast( &m_ownActions ); } -QString KonqPopupMenu::mimeType( ){ +QString KonqPopupMenu::mimeType( ) const { return m_sMimeType; } void KonqPopupMenu::addPlugins( ){ -// search for Konq_PopupMenuPlugins inspired by simons kpropsdlg -//search for a plugin with the right protocol + // search for Konq_PopupMenuPlugins inspired by simons kpropsdlg + //search for a plugin with the right protocol KTrader::OfferList plugin_offers = KTrader::self()->query(m_sMimeType, "'KonqPopupMenu/Plugin' in ServiceTypes"); KTrader::OfferList::ConstIterator iterator = plugin_offers.begin( ); KTrader::OfferList::ConstIterator end = plugin_offers.end( ); // travers the offerlist for(; iterator != end; ++iterator ){ - QString libName = (*iterator)->library( ); - if( libName.isEmpty( ) ) // if there is no lib go to the next offer - - continue; - KLibrary *lib = KLibLoader::self()->library( libName.local8Bit() ); - if ( !lib ) - continue; - KLibFactory *factory = lib->factory( ); - if (!factory ) { - delete lib; - continue; - } - QObject *obj = factory->create( this, (*iterator)->name().latin1(), "KonqPopupMenuPlugin" ); - if ( !obj ) { - delete lib; - //delete factory; // makes sense but Simon didn't do it? so what? - continue; - } - if ( !obj->inherits("KonqPopupMenuPlugin") ){ - delete obj; + KonqPopupMenuPlugin *plugin = + KParts::ComponentFactory:: + createInstanceFromLibrary( (*iterator)->library().local8Bit(), + this, + (*iterator)->name().latin1() ); + if ( !plugin ) continue; - //delete lib; // is this necessary? - //delete factory; // is this necessary? - } - KonqPopupMenuPlugin *plugin = static_cast( obj ); - if ( !plugin ){ - delete obj; - continue; - } - //connect(this, SIGNAL(XMLGUIFinished() ), plugin, SLOT(slotXMLGUIFinished() ) ); m_pluginList.append( plugin ); - insertChildClient( plugin ); - addMerge( 0 ); + insertChildClient( plugin ); + addMerge( 0 ); } } @@ -604,7 +582,7 @@ KURL::List KonqPopupMenu::popupURLList( Plugin */ -KonqPopupMenuPlugin::KonqPopupMenuPlugin( KonqPopupMenu *_popup ){ +KonqPopupMenuPlugin::KonqPopupMenuPlugin( KonqPopupMenu * ){ } KonqPopupMenuPlugin::~KonqPopupMenuPlugin( ){ Index: konq_popupmenu.h =================================================================== RCS file: /home/kde/kdebase/libkonq/konq_popupmenu.h,v retrieving revision 1.25 diff -u -p -r1.25 konq_popupmenu.h --- konq_popupmenu.h 2001/10/30 18:09:01 1.25 +++ konq_popupmenu.h 2001/10/31 07:01:06 @@ -78,7 +78,7 @@ public: virtual KActionCollection *actionCollection() const; - QString mimeType( ); + QString mimeType( ) const; KURL url( ) const; KFileItemList fileItemList() const; KURL::List popupURLList( ) const; Index: konq_xmlguiclient.cc =================================================================== RCS file: /home/kde/kdebase/libkonq/konq_xmlguiclient.cc,v retrieving revision 1.1 diff -u -p -r1.1 konq_xmlguiclient.cc --- konq_xmlguiclient.cc 2001/10/30 18:09:01 1.1 +++ konq_xmlguiclient.cc 2001/10/31 07:01:06 @@ -49,7 +49,7 @@ void KonqXMLGUIClient::prepareXMLGUIStuf m_factory = new KXMLGUIFactory( m_builder ); */ } -QDomElement KonqXMLGUIClient::DomElement( ) const { +QDomElement KonqXMLGUIClient::menuElement( ) const { return m_menuElement; } QDomDocument KonqXMLGUIClient::domDocument( ) const { @@ -100,4 +100,4 @@ void KonqXMLGUIClient::addGroup( const Q group.setAttribute( "name", grp ); } KonqXMLGUIClient::~KonqXMLGUIClient( ){ -} \ No newline at end of file +} Index: konq_xmlguiclient.h =================================================================== RCS file: /home/kde/kdebase/libkonq/konq_xmlguiclient.h,v retrieving revision 1.1 diff -u -p -r1.1 konq_xmlguiclient.h --- konq_xmlguiclient.h 2001/10/30 18:09:01 1.1 +++ konq_xmlguiclient.h 2001/10/31 07:01:06 @@ -26,8 +26,8 @@ #include #include /** This class implements common methods to manipulate the DOMDocument of KXMLGUIClient - * - */ + * + */ class KonqXMLGUIClient : public KXMLGUIClient { public: @@ -39,7 +39,7 @@ public: */ QDomDocument domDocument( ) const; - QDomElement DomElement( ) const; + QDomElement menuElement( ) const; protected: void addAction( KAction *action, const QDomElement &menu = QDomElement() ); @@ -47,10 +47,10 @@ protected: void addSeparator( const QDomElement &menu = QDomElement() ); void addGroup( const QString &grp ); void addMerge( const char *name ); - void prepareXMLGUIStuff(); + void prepareXMLGUIStuff(); QDomDocument m_doc; QDomElement m_menuElement; - QString attrName; + QString attrName; }; #endif --1yeeQ81UyVL57Vl7--