summaryrefslogtreecommitdiffabout
path: root/microkde/kdecore/klibloader.cpp
Unidiff
Diffstat (limited to 'microkde/kdecore/klibloader.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/klibloader.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/microkde/kdecore/klibloader.cpp b/microkde/kdecore/klibloader.cpp
index 6d0475a..0b54eb6 100644
--- a/microkde/kdecore/klibloader.cpp
+++ b/microkde/kdecore/klibloader.cpp
@@ -17,15 +17,18 @@
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19//US #include <config.h> 19//US #include <config.h>
20#include <qclipboard.h> 20#include <qclipboard.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qobjectdict.h> 23#include <q3objectdict.h>
24#include <qwidgetlist.h>
25#include <qwidget.h> 24#include <qwidget.h>
25#include <qwidget.h>
26//Added by qt3to4:
27#include <Q3CString>
28#include <Q3PtrList>
26 29
27#include "kapplication.h" 30#include "kapplication.h"
28#include "klibloader.h" 31#include "klibloader.h"
29#include "kstandarddirs.h" 32#include "kstandarddirs.h"
30#include "kdebug.h" 33#include "kdebug.h"
31#include "klocale.h" 34#include "klocale.h"
@@ -42,13 +45,13 @@
42#include <qtopia/qlibrary.h> 45#include <qtopia/qlibrary.h>
43#else 46#else
44#include <qlibrary.h> 47#include <qlibrary.h>
45#endif 48#endif
46 49
47 50
48template class QAsciiDict<KLibrary>; 51template class Q3AsciiDict<KLibrary>;
49 52
50#include <stdlib.h> //getenv 53#include <stdlib.h> //getenv
51 54
52/*US 55/*US
53#if HAVE_DLFCN_H 56#if HAVE_DLFCN_H
54# include <dlfcn.h> 57# include <dlfcn.h>
@@ -117,13 +120,13 @@ KLibrary::~KLibrary()
117 if ( m_timer && m_timer->isActive() ) 120 if ( m_timer && m_timer->isActive() )
118 m_timer->stop(); 121 m_timer->stop();
119 122
120 // If any object is remaining, delete 123 // If any object is remaining, delete
121 if ( m_objs.count() > 0 ) 124 if ( m_objs.count() > 0 )
122 { 125 {
123 QPtrListIterator<QObject> it( m_objs ); 126 Q3PtrListIterator<QObject> it( m_objs );
124 for ( ; it.current() ; ++it ) 127 for ( ; it.current() ; ++it )
125 { 128 {
126 kdDebug(150) << "Factory still has object " << it.current() << " " << it.current()->name () << " Library = " << m_libname << endl; 129 kdDebug(150) << "Factory still has object " << it.current() << " " << it.current()->name () << " Library = " << m_libname << endl;
127 disconnect( it.current(), SIGNAL( destroyed() ), 130 disconnect( it.current(), SIGNAL( destroyed() ),
128 this, SLOT( slotObjectDestroyed() ) ); 131 this, SLOT( slotObjectDestroyed() ) );
129 } 132 }
@@ -149,13 +152,13 @@ QString KLibrary::fileName() const
149 152
150KLibFactory* KLibrary::factory() 153KLibFactory* KLibrary::factory()
151{ 154{
152 if ( m_factory ) 155 if ( m_factory )
153 return m_factory; 156 return m_factory;
154 157
155 QCString symname; 158 Q3CString symname;
156 symname.sprintf("init_%s", name().latin1() ); 159 symname.sprintf("init_%s", name().latin1() );
157 160
158 void* sym = symbol( symname ); 161 void* sym = symbol( symname );
159 if ( !sym ) 162 if ( !sym )
160 { 163 {
161 qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data()); 164 qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data());
@@ -302,14 +305,14 @@ KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, QLibrary* h)
302 } 305 }
303} 306}
304 307
305class KLibLoaderPrivate 308class KLibLoaderPrivate
306{ 309{
307public: 310public:
308 QPtrList<KLibWrapPrivate> loaded_stack; 311 Q3PtrList<KLibWrapPrivate> loaded_stack;
309 QPtrList<KLibWrapPrivate> pending_close; 312 Q3PtrList<KLibWrapPrivate> pending_close;
310 enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; 313 enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode;
311 314
312 QString errorMessage; 315 QString errorMessage;
313}; 316};
314 317
315KLibLoader* KLibLoader::s_self = 0; 318KLibLoader* KLibLoader::s_self = 0;
@@ -345,13 +348,13 @@ KLibLoader::KLibLoader( QObject* parent, const char* name )
345} 348}
346 349
347KLibLoader::~KLibLoader() 350KLibLoader::~KLibLoader()
348{ 351{
349// kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl; 352// kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl;
350 353
351 QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); 354 Q3AsciiDictIterator<KLibWrapPrivate> it( m_libs );
352 for (; it.current(); ++it ) 355 for (; it.current(); ++it )
353 { 356 {
354 kdDebug(150) << "The KLibLoader contains the library " << it.current()->name 357 kdDebug(150) << "The KLibLoader contains the library " << it.current()->name
355 << " (" << it.current()->lib << ")" << endl; 358 << " (" << it.current()->lib << ")" << endl;
356 d->pending_close.append(it.current()); 359 d->pending_close.append(it.current());
357 } 360 }
@@ -361,13 +364,13 @@ KLibLoader::~KLibLoader()
361 delete d; 364 delete d;
362} 365}
363 366
364//static 367//static
365QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ ) 368QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ )
366{ 369{
367 QCString libname( name ); 370 Q3CString libname( name );
368 371
369 // only append ".la" if there is no extension 372 // only append ".la" if there is no extension
370 // this allows to load non-libtool libraries as well 373 // this allows to load non-libtool libraries as well
371 // (mhk, 20000228) 374 // (mhk, 20000228)
372 int pos = libname.findRev('/'); 375 int pos = libname.findRev('/');
373 if (pos < 0) 376 if (pos < 0)
@@ -418,13 +421,13 @@ QString KLibLoader::findLibrary( const char * name/*US , const KInstance * insta
418#endif 421#endif
419 } 422 }
420 if ( libfile.isEmpty() ) 423 if ( libfile.isEmpty() )
421 { 424 {
422#ifndef NDEBUG 425#ifndef NDEBUG
423 kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl; 426 kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl;
424 self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(libname); 427 self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(QString(libname));
425 428
426 qDebug("KLibLoader::library could not find library: %s", libname.data()); 429 qDebug("KLibLoader::library could not find library: %s", libname.data());
427#endif 430#endif
428 431
429 } 432 }
430 else 433 else
@@ -466,13 +469,13 @@ KLibrary* KLibLoader::library( const char *name )
466 wrap->ref_count++; 469 wrap->ref_count++;
467 return wrap->lib; 470 return wrap->lib;
468 } 471 }
469 472
470 /* Test if this library was loaded at some time, but got 473 /* Test if this library was loaded at some time, but got
471 unloaded meanwhile, whithout being dlclose()'ed. */ 474 unloaded meanwhile, whithout being dlclose()'ed. */
472 QPtrListIterator<KLibWrapPrivate> it(d->loaded_stack); 475 Q3PtrListIterator<KLibWrapPrivate> it(d->loaded_stack);
473 for (; it.current(); ++it) { 476 for (; it.current(); ++it) {
474 if (it.current()->name == name) 477 if (it.current()->name == name)
475 wrap = it.current(); 478 wrap = it.current();
476 } 479 }
477 480
478 if (wrap) { 481 if (wrap) {
@@ -547,13 +550,13 @@ KLibFactory* KLibLoader::factory( const char* name )
547} 550}
548 551
549void KLibLoader::slotLibraryDestroyed() 552void KLibLoader::slotLibraryDestroyed()
550{ 553{
551 const KLibrary *lib = static_cast<const KLibrary *>( sender() ); 554 const KLibrary *lib = static_cast<const KLibrary *>( sender() );
552 555
553 QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); 556 Q3AsciiDictIterator<KLibWrapPrivate> it( m_libs );
554 for (; it.current(); ++it ) 557 for (; it.current(); ++it )
555 if ( it.current()->lib == lib ) 558 if ( it.current()->lib == lib )
556 { 559 {
557 KLibWrapPrivate *wrap = it.current(); 560 KLibWrapPrivate *wrap = it.current();
558 wrap->lib = 0; /* the KLibrary object is already away */ 561 wrap->lib = 0; /* the KLibrary object is already away */
559 m_libs.remove( it.currentKey() ); 562 m_libs.remove( it.currentKey() );
@@ -566,13 +569,13 @@ void KLibLoader::close_pending(KLibWrapPrivate *wrap)
566{ 569{
567 if (wrap && !d->pending_close.containsRef( wrap )) 570 if (wrap && !d->pending_close.containsRef( wrap ))
568 d->pending_close.append( wrap ); 571 d->pending_close.append( wrap );
569 572
570 /* First delete all KLibrary objects in pending_close, but _don't_ unload 573 /* First delete all KLibrary objects in pending_close, but _don't_ unload
571 the DSO behind it. */ 574 the DSO behind it. */
572 QPtrListIterator<KLibWrapPrivate> it(d->pending_close); 575 Q3PtrListIterator<KLibWrapPrivate> it(d->pending_close);
573 for (; it.current(); ++it) { 576 for (; it.current(); ++it) {
574 wrap = it.current(); 577 wrap = it.current();
575 if (wrap->lib) { 578 if (wrap->lib) {
576 disconnect( wrap->lib, SIGNAL( destroyed() ), 579 disconnect( wrap->lib, SIGNAL( destroyed() ),
577 this, SLOT( slotLibraryDestroyed() ) ); 580 this, SLOT( slotLibraryDestroyed() ) );
578 delete wrap->lib; 581 delete wrap->lib;