rendered paste bodyIndex: klibloader.cpp
===================================================================
--- klibloader.cpp (wersja 731542)
+++ klibloader.cpp (kopia robocza)
@@ -59,41 +59,33 @@
extern QString makeLibName( const QString &libname );
-extern QString findLibraryInternal(const QString &name, const KComponentData &cData);
+extern QString findLibrary(const QString &name, const KComponentData &cData);
-//static
-QString KLibLoader::findLibrary(const QString &_name, const KComponentData &cData)
-{
- QString libname = findLibraryInternal(QDir::fromNativeSeparators(_name), cData);
#ifdef Q_OS_WIN
- // we don't have 'lib' prefix on windows -> remove it and try again
- if( libname.isEmpty() )
+// removes "lib" prefix, if present
+QString fixLibPrefix(const QString& libname)
+{
+ int pos = libname.lastIndexOf( '/' );
+ if ( pos >= 0 )
{
- libname = _name;
- QString file, path;
-
- int pos = libname.lastIndexOf( '/' );
- if ( pos >= 0 )
- {
- file = libname.mid( pos + 1 );
- path = libname.left( pos );
- libname = path + '/' + file.mid( 3 );
- }
- else
- {
- file = libname;
- libname = file.mid( 3 );
- }
- if( !file.startsWith( "lib" ) )
- return libname;
-
- libname = findLibraryInternal(libname, cData);
+ QString file = libname.mid( pos + 1 );
+ QString path = libname.left( pos );
+ if( !file.startsWith( "lib" ) )
+ return libname;
+ return path + '/' + file.mid( 3 );
}
+ if( !libname.startsWith( "lib" ) )
+ return libname;
+ return libname.mid( 3 );
+}
#endif
- return libname;
+
+//static
+QString KLibLoader::findLibrary(const QString &_name, const KComponentData &cData)
+{
+ return ::findLibrary(_name, cData);
}
-
KLibrary* KLibLoader::library( const QString &_name, QLibrary::LoadHints hint )
{
if (_name.isEmpty())
Index: klibrary.cpp
===================================================================
--- klibrary.cpp (wersja 734474)
+++ klibrary.cpp (kopia robocza)
@@ -113,6 +113,11 @@
t_func func = reinterpret_cast<t_func>(lib->resolveFunction( symname ));
if ( !func )
{
+#ifdef Q_OS_WIN
+ // a backup for cases when developer has set lib prefix for a plugin name (she should not...)
+ if (!factoryname.startsWith("lib"))
+ return kde3Factory(lib, QByteArray("lib")+symname.mid(5 /*"init_"*/));
+#endif
kDebug(150) << "The library" << lib->fileName() << "does not offer an"
<< symname << "function.";
return 0;
Index: kpluginloader.cpp
===================================================================
--- kpluginloader.cpp (wersja 731542)
+++ kpluginloader.cpp (kopia robocza)
@@ -73,22 +73,28 @@
#endif
}
+#ifdef Q_OS_WIN
+extern QString fixLibPrefix(const QString& libname);
+#endif
+
inline QString findLibraryInternal(const QString &name, const KComponentData &cData)
{
QString libname = makeLibName(name);
QFileInfo fileinfo(name);
- bool hasPraefix = fileinfo.fileName().startsWith("lib");
+ bool hasPrefix = fileinfo.fileName().startsWith("lib");
- if (hasPraefix)
+ if (hasPrefix)
kDebug(150) << "plugins shouldn't have a 'lib' suffix:" << libname;
QString libfile;
if (QDir::isRelativePath(libname)) {
libfile = cData.dirs()->findResource("module", libname);
if (libfile.isEmpty()) {
-#ifndef Q_OS_WIN
- if (!hasPraefix)
+#ifdef Q_OS_WIN
+ libname = fixLibPrefix(libname);
+#else
+ if (!hasPrefix)
libname = fileinfo.path() + QLatin1String("/lib") + fileinfo.fileName();
#endif
libfile = cData.dirs()->findResource("lib", libname);