-rw-r--r-- | library/qpeapplication.cpp | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 76d62ef..6e2db7c 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -74,2 +74,5 @@ | |||
74 | #include "lightstyle.h" | 74 | #include "lightstyle.h" |
75 | |||
76 | #include <qpe/qlibrary.h> | ||
77 | #include <dlfcn.h> | ||
75 | #endif | 78 | #endif |
@@ -103,3 +106,2 @@ | |||
103 | 106 | ||
104 | #include <dlfcn.h> // for Liquid HACK | ||
105 | 107 | ||
@@ -1330,19 +1332,46 @@ void QPEApplication::internalSetStyle( const QString &style ) | |||
1330 | // HACK for Qt2 only | 1332 | // HACK for Qt2 only |
1331 | else if ( style == "Liquid" ) { | 1333 | else { |
1332 | static void *lib = 0; | 1334 | // style == "Liquid Style (libliquid.so)" (or "Windows XP (libxp.so)" |
1333 | QStyle *sty = 0; | ||
1334 | 1335 | ||
1336 | int p2 = style. findRev ( ']' ); | ||
1337 | int p1 = style. findRev ( '[' ); | ||
1338 | QString style2; | ||
1339 | |||
1340 | if (( p1 > 0 ) && ( p2 > 0 ) && (( p1 + 1 ) < p2 )) | ||
1341 | style2 = "lib" + style. mid ( p1 + 1, p2 - p1 - 1 ). lower ( ) + ".so"; | ||
1342 | else | ||
1343 | style2 = "lib" + style. lower ( ) + ".so"; | ||
1344 | |||
1345 | // static QLibrary *currentlib = 0; | ||
1346 | static void *currentlib = 0; | ||
1347 | |||
1348 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/" + style2; | ||
1349 | |||
1350 | do { // try/catch simulation | ||
1351 | // QLibrary *lib = new QLibrary ( path, QLibrary::Immediately ); | ||
1352 | void *lib = ::dlopen ( path. local8Bit ( ), RTLD_NOW | RTLD_GLOBAL ); | ||
1335 | 1353 | ||
1336 | if ( !lib ) { | ||
1337 | QString path = QPEApplication::qpeDir() + "/plugins/styles/" + "libliquid.so"; | ||
1338 | lib = ::dlopen ( path. local8Bit ( ), RTLD_NOW | RTLD_GLOBAL ); | ||
1339 | } | ||
1340 | if ( lib ) { | 1354 | if ( lib ) { |
1341 | void *sym = ::dlsym ( lib, "allocate" ); | 1355 | //QStyle * (*fpa) ( ) = (QStyle * (*) ( )) lib-> resolve ( "allocate" ); |
1356 | QStyle * (*fpa) ( ) = (QStyle * (*) ( )) ::dlsym ( lib, "allocate" ); | ||
1342 | 1357 | ||
1343 | if ( sym ) | 1358 | if ( fpa ) { |
1344 | sty = ((QStyle * (*) ( )) sym ) ( ); | 1359 | QStyle *sty = ( *fpa ) ( ); |
1345 | } | 1360 | |
1346 | if ( sty ) | 1361 | if ( sty ) { |
1347 | setStyle ( sty ); | 1362 | setStyle ( sty ); |
1363 | |||
1364 | if ( currentlib ) { | ||
1365 | //delete currentlib; | ||
1366 | ::dlclose ( currentlib ); | ||
1367 | } | ||
1368 | currentlib = lib; | ||
1369 | |||
1370 | break; | ||
1371 | } | ||
1372 | } | ||
1373 | //delete lib; | ||
1374 | ::dlclose ( lib ); | ||
1375 | } | ||
1376 | } while ( false ); | ||
1348 | } | 1377 | } |