Diffstat (limited to 'microkde/kdecore/klibloader.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | microkde/kdecore/klibloader.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/microkde/kdecore/klibloader.cpp b/microkde/kdecore/klibloader.cpp index c07d50f..c091e05 100644 --- a/microkde/kdecore/klibloader.cpp +++ b/microkde/kdecore/klibloader.cpp | |||
@@ -31,32 +31,29 @@ | |||
31 | #include "klocale.h" | 31 | #include "klocale.h" |
32 | 32 | ||
33 | /*US | 33 | /*US |
34 | #ifndef NDEBUG | 34 | #ifndef NDEBUG |
35 | #include "ltdl.h" | 35 | #include "ltdl.h" |
36 | #endif | 36 | #endif |
37 | */ | 37 | */ |
38 | 38 | ||
39 | //US do everything through qlibrary | 39 | //US do everything through qlibrary |
40 | #ifndef DESKTOP_VERSION | 40 | #ifndef DESKTOP_VERSION |
41 | #include <qpe/qpeapplication.h> | 41 | #include <qpe/qpeapplication.h> |
42 | #include <qtopia/qlibrary.h> | 42 | #include <qtopia/qlibrary.h> |
43 | #else | ||
44 | #include <qlibrary.h> | ||
43 | #endif | 45 | #endif |
44 | 46 | ||
45 | /*US | 47 | |
46 | #ifdef Q_WS_X11 | ||
47 | #include <X11/Xlib.h> | ||
48 | #include <X11/Xatom.h> | ||
49 | #endif | ||
50 | */ | ||
51 | template class QAsciiDict<KLibrary>; | 48 | template class QAsciiDict<KLibrary>; |
52 | 49 | ||
53 | #include <stdlib.h> //getenv | 50 | #include <stdlib.h> //getenv |
54 | 51 | ||
55 | /*US | 52 | /*US |
56 | #if HAVE_DLFCN_H | 53 | #if HAVE_DLFCN_H |
57 | # include <dlfcn.h> | 54 | # include <dlfcn.h> |
58 | #endif | 55 | #endif |
59 | 56 | ||
60 | #ifdef RTLD_GLOBAL | 57 | #ifdef RTLD_GLOBAL |
61 | # define LT_GLOBAL RTLD_GLOBAL | 58 | # define LT_GLOBAL RTLD_GLOBAL |
62 | #else | 59 | #else |
@@ -183,25 +180,24 @@ KLibFactory* KLibrary::factory() | |||
183 | this, SLOT( slotObjectCreated( QObject * ) ) ); | 180 | this, SLOT( slotObjectCreated( QObject * ) ) ); |
184 | 181 | ||
185 | return m_factory; | 182 | return m_factory; |
186 | } | 183 | } |
187 | 184 | ||
188 | void* KLibrary::symbol( const char* symname ) const | 185 | void* KLibrary::symbol( const char* symname ) const |
189 | { | 186 | { |
190 | //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); | 187 | //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); |
191 | void* sym = m_handle->resolve( symname ); | 188 | void* sym = m_handle->resolve( symname ); |
192 | if ( !sym ) | 189 | if ( !sym ) |
193 | { | 190 | { |
194 | //US kdWarning(150) << "KLibrary: " << lt_dlerror() << endl; | 191 | //US kdWarning(150) << "KLibrary: " << lt_dlerror() << endl; |
195 | kdWarning(150) << "KLibrary: " << m_libname << ", symbol:" << symname << " not found " << endl; | ||
196 | return 0; | 192 | return 0; |
197 | } | 193 | } |
198 | 194 | ||
199 | return sym; | 195 | return sym; |
200 | } | 196 | } |
201 | 197 | ||
202 | bool KLibrary::hasSymbol( const char* symname ) const | 198 | bool KLibrary::hasSymbol( const char* symname ) const |
203 | { | 199 | { |
204 | //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); | 200 | //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); |
205 | void* sym = m_handle->resolve( symname ); | 201 | void* sym = m_handle->resolve( symname ); |
206 | return (sym != 0L ); | 202 | return (sym != 0L ); |
207 | } | 203 | } |
@@ -468,26 +464,29 @@ KLibrary* KLibLoader::library( const char *name ) | |||
468 | 464 | ||
469 | if (wrap) { | 465 | if (wrap) { |
470 | d->pending_close.removeRef(wrap); | 466 | d->pending_close.removeRef(wrap); |
471 | if (!wrap->lib) { | 467 | if (!wrap->lib) { |
472 | /* This lib only was in loaded_stack, but not in m_libs. */ | 468 | /* This lib only was in loaded_stack, but not in m_libs. */ |
473 | wrap->lib = new KLibrary( name, wrap->filename, wrap->handle ); | 469 | wrap->lib = new KLibrary( name, wrap->filename, wrap->handle ); |
474 | } | 470 | } |
475 | wrap->ref_count++; | 471 | wrap->ref_count++; |
476 | } else { | 472 | } else { |
477 | QString libfile = findLibrary( name ); | 473 | QString libfile = findLibrary( name ); |
478 | if ( libfile.isEmpty() ) | 474 | if ( libfile.isEmpty() ) |
479 | return 0; | 475 | return 0; |
480 | 476 | #ifdef DESKTOP_VERSION | |
477 | QLibrary *qlib = new QLibrary( libfile.latin1() ); | ||
478 | #else | ||
481 | QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately ); | 479 | QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately ); |
480 | #endif | ||
482 | 481 | ||
483 | //US lt_dlhandle handle = lt_dlopen( libfile.latin1() ); | 482 | //US lt_dlhandle handle = lt_dlopen( libfile.latin1() ); |
484 | //US if ( !handle ) | 483 | //US if ( !handle ) |
485 | if ( !qlib ) | 484 | if ( !qlib ) |
486 | { | 485 | { |
487 | //US const char* errmsg = lt_dlerror(); | 486 | //US const char* errmsg = lt_dlerror(); |
488 | char* errmsg; | 487 | char* errmsg; |
489 | sprintf(errmsg, "KLibLoader::library could not load library: %s", libfile.latin1()); | 488 | sprintf(errmsg, "KLibLoader::library could not load library: %s", libfile.latin1()); |
490 | qDebug(errmsg); | 489 | qDebug(errmsg); |
491 | 490 | ||
492 | if(errmsg) | 491 | if(errmsg) |
493 | d->errorMessage = QString::fromLatin1(errmsg); | 492 | d->errorMessage = QString::fromLatin1(errmsg); |
@@ -590,24 +589,25 @@ void KLibLoader::close_pending(KLibWrapPrivate *wrap) | |||
590 | 589 | ||
591 | /* Now ensure, that the libs are only unloaded in the reverse direction | 590 | /* Now ensure, that the libs are only unloaded in the reverse direction |
592 | they were loaded. */ | 591 | they were loaded. */ |
593 | if (!d->pending_close.containsRef( wrap )) { | 592 | if (!d->pending_close.containsRef( wrap )) { |
594 | if (!deleted_one) | 593 | if (!deleted_one) |
595 | /* Only diagnose, if we really haven't deleted anything. */ | 594 | /* Only diagnose, if we really haven't deleted anything. */ |
596 | // kdDebug(150) << "try to dlclose " << wrap->name << ": not yet" << endl; | 595 | // kdDebug(150) << "try to dlclose " << wrap->name << ": not yet" << endl; |
597 | break; | 596 | break; |
598 | } | 597 | } |
599 | 598 | ||
600 | // kdDebug(150) << "try to dlclose " << wrap->name << ": yes, done." << endl; | 599 | // kdDebug(150) << "try to dlclose " << wrap->name << ": yes, done." << endl; |
601 | 600 | ||
601 | #if 0 | ||
602 | #ifndef Q_WS_QWS | 602 | #ifndef Q_WS_QWS |
603 | if ( !deleted_one ) { | 603 | if ( !deleted_one ) { |
604 | /* Only do the hack once in this loop. | 604 | /* Only do the hack once in this loop. |
605 | WABA: *HACK* | 605 | WABA: *HACK* |
606 | We need to make sure to clear the clipboard before unloading a DSO | 606 | We need to make sure to clear the clipboard before unloading a DSO |
607 | because the DSO could have defined an object derived from QMimeSource | 607 | because the DSO could have defined an object derived from QMimeSource |
608 | and placed that on the clipboard. */ | 608 | and placed that on the clipboard. */ |
609 | /*kapp->clipboard()->clear();*/ | 609 | /*kapp->clipboard()->clear();*/ |
610 | 610 | ||
611 | /* Well.. let's do something more subtle... convert the clipboard context | 611 | /* Well.. let's do something more subtle... convert the clipboard context |
612 | to text. That should be safe as it only uses objects defined by Qt. */ | 612 | to text. That should be safe as it only uses objects defined by Qt. */ |
613 | 613 | ||
@@ -619,24 +619,25 @@ void KLibLoader::close_pending(KLibWrapPrivate *wrap) | |||
619 | kapp->clipboard()->setText(kapp->clipboard()->text()); | 619 | kapp->clipboard()->setText(kapp->clipboard()->text()); |
620 | 620 | ||
621 | break; | 621 | break; |
622 | } | 622 | } |
623 | co = widgetlist->next(); | 623 | co = widgetlist->next(); |
624 | } | 624 | } |
625 | delete widgetlist; | 625 | delete widgetlist; |
626 | } | 626 | } |
627 | #else | 627 | #else |
628 | // FIXME(E): Implement in Qt Embedded | 628 | // FIXME(E): Implement in Qt Embedded |
629 | #endif | 629 | #endif |
630 | 630 | ||
631 | #endif // 0 | ||
631 | deleted_one = true; | 632 | deleted_one = true; |
632 | //US lt_dlclose(wrap->handle); | 633 | //US lt_dlclose(wrap->handle); |
633 | wrap->handle->unload(); | 634 | wrap->handle->unload(); |
634 | 635 | ||
635 | d->pending_close.removeRef(wrap); | 636 | d->pending_close.removeRef(wrap); |
636 | /* loaded_stack is AutoDelete, so wrap is freed */ | 637 | /* loaded_stack is AutoDelete, so wrap is freed */ |
637 | d->loaded_stack.remove(); | 638 | d->loaded_stack.remove(); |
638 | } | 639 | } |
639 | } | 640 | } |
640 | 641 | ||
641 | void KLibLoader::virtual_hook( int, void* ) | 642 | void KLibLoader::virtual_hook( int, void* ) |
642 | { /*BASE::virtual_hook( id, data );*/ } | 643 | { /*BASE::virtual_hook( id, data );*/ } |