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

List:       kde-core-devel
Subject:    KParts / plugi loading and encoding
From:       Christian Ehrlicher <Ch.Ehrlicher () gmx ! de>
Date:       2009-02-27 16:12:19
Message-ID: 49A810E3.2060408 () gmx ! de
[Download RAW message or body]

Hi,

once more an encoding problem...

KParts Plugin::loadPlugin() currently needs a const char * as libname 
which is wrong (it also superflous because it gets converted back to a 
QString when KLibLoader::createInstance() is called).

Therefore I wanted to deprecate this function and add loadPlugin() which 
takes a QString. While this looks BC to me it's not SC because it will 
break compile when a QByteArray is given to loadPlugin.
-->
loadPlugin( parent, QFile::encodeName( library ) ) will result in error 
about a ambiguous call to loadPlugin... :(

Any ideas how to fix this?

Thx,
Christian

["kparts.patch" (text/x-patch)]

Index: plugin.cpp
===================================================================
--- plugin.cpp	(revision 932439)
+++ plugin.cpp	(working copy)
@@ -150,7 +150,7 @@
      if ( library.isEmpty() || hasPlugin( parent, library ) )
        continue;
 
-     Plugin *plugin = loadPlugin( parent, QFile::encodeName(library) );
+     Plugin *plugin = loadPlugin( parent, library );
 
      if ( plugin )
      {
@@ -168,7 +168,7 @@
    loadPlugins(parent, pluginInfos, KComponentData());
 }
 
-// static
+// static, deprecated
 Plugin* Plugin::loadPlugin( QObject * parent, const char* libname )
 {
     Plugin* plugin = KLibLoader::createInstance<Plugin>( libname, parent );
@@ -178,6 +178,16 @@
     return plugin;
 }
 
+// static
+Plugin* Plugin::loadPlugin( QObject * parent, const QString &libname )
+{
+    Plugin* plugin = KLibLoader::createInstance<Plugin>( libname, parent );
+    if ( !plugin )
+        return 0;
+    plugin->d->m_library = libname;
+    return plugin;
+}
+
 QList<KParts::Plugin *> Plugin::pluginObjects( QObject *parent )
 {
   QList<KParts::Plugin *> objects;
@@ -304,7 +314,7 @@
             continue;
 
         kDebug( 1000 ) << "load plugin " << name;
-        Plugin *plugin = loadPlugin( parent, QFile::encodeName(library) );
+        Plugin *plugin = loadPlugin( parent, library );
 
         if ( plugin )
         {
Index: plugin.h
===================================================================
--- plugin.h	(revision 932439)
+++ plugin.h	(working copy)
@@ -170,8 +170,14 @@
      * @internal
      * @return The plugin created from the library @p libname
      */
-    static Plugin* loadPlugin( QObject * parent, const char* libname );
+    KDE_DEPRECATED static Plugin* loadPlugin( QObject * parent, const char* libname );
 
+    /**
+     * @internal
+     * @return The plugin created from the library @p libname
+     */
+    static Plugin* loadPlugin( QObject * parent, const QString &libname );
+
     virtual void setComponentData(const KComponentData &instance);
 
 private:


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

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