author | ulf69 <ulf69> | 2004-06-29 05:03:25 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-06-29 05:03:25 (UTC) |
commit | 0538ac1cc17ad4249d27d686b4bc7e80663f475f (patch) (side-by-side diff) | |
tree | abf571d0e2640bbb7ce14818a376ad980492ea05 /microkde | |
parent | 61ef87224517601f8754dd9da1b521a7b0094558 (diff) | |
download | kdepimpi-0538ac1cc17ad4249d27d686b4bc7e80663f475f.zip kdepimpi-0538ac1cc17ad4249d27d686b4bc7e80663f475f.tar.gz kdepimpi-0538ac1cc17ad4249d27d686b4bc7e80663f475f.tar.bz2 |
*** empty log message ***
-rw-r--r-- | microkde/kdecore/klibloader.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/microkde/kdecore/klibloader.cpp b/microkde/kdecore/klibloader.cpp index 1410308..130cc7c 100644 --- a/microkde/kdecore/klibloader.cpp +++ b/microkde/kdecore/klibloader.cpp @@ -128,65 +128,66 @@ KLibrary::~KLibrary() } m_objs.setAutoDelete(true); m_objs.clear(); } if ( m_factory ) { // kdDebug(150) << " ... deleting the factory " << m_factory << endl; delete m_factory; } } QString KLibrary::name() const { return m_libname; } QString KLibrary::fileName() const { return m_filename; } KLibFactory* KLibrary::factory() { if ( m_factory ) return m_factory; QCString symname; symname.sprintf("init_%s", name().latin1() ); void* sym = symbol( symname ); if ( !sym ) { - kdWarning(150) << "KLibrary: The library " << name() << " does not offer an init_" << name() << " function" << endl; + qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data()); + kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl; return 0; } typedef KLibFactory* (*t_func)(); t_func func = (t_func)sym; m_factory = func(); if( !m_factory ) { kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl; return 0; } connect( m_factory, SIGNAL( objectCreated( QObject * ) ), this, SLOT( slotObjectCreated( QObject * ) ) ); return m_factory; } void* KLibrary::symbol( const char* symname ) const { //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); void* sym = m_handle->resolve( symname ); if ( !sym ) { //US kdWarning(150) << "KLibrary: " << lt_dlerror() << endl; kdWarning(150) << "KLibrary: " << m_libname << ", symbol:" << symname << " not found " << endl; return 0; } return sym; } @@ -339,153 +340,166 @@ KLibLoader::KLibLoader( QObject* parent, const char* name ) d->unload_mode = KLibLoaderPrivate::UNLOAD; d->loaded_stack.setAutoDelete( true ); } KLibLoader::~KLibLoader() { // kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl; QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); for (; it.current(); ++it ) { kdDebug(150) << "The KLibLoader contains the library " << it.current()->name << " (" << it.current()->lib << ")" << endl; d->pending_close.append(it.current()); } close_pending(0); delete d; } //static QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ ) { QCString libname( name ); // only append ".la" if there is no extension // this allows to load non-libtool libraries as well // (mhk, 20000228) int pos = libname.findRev('/'); if (pos < 0) pos = 0; - if (libname.find('.', pos) < 0) +/*US + if (libname.find('.', pos) < 0) { libname += ".la"; + } +*/ +//US in the microedition we work only with shared libraries. + if (libname.find('.', pos) < 0) { + libname += ".so"; + } // only look up the file if it is not an absolute filename // (mhk, 20000228) QString libfile; if (libname[0] == '/') libfile = libname; else { +//US at this point the libname must exist as real filesname. No expansions will be made later +// in findResources. Because of that we prepend the lib prefix here to the name +//US I add also the "lib" prefix. I do not how could this could have worked before without it? + libname.insert(pos, "lib"); + + //US libfile = instance->dirs()->findResource( "module", libname ); libfile = KGlobal::dirs()->findResource( "module", libname ); if ( libfile.isEmpty() ) { //US libfile = instance->dirs()->findResource( "lib", libname ); libfile = KGlobal::dirs()->findResource( "lib", libname ); #ifndef NDEBUG if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl; #endif } if ( libfile.isEmpty() ) { #ifndef NDEBUG kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl; #endif self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(libname); + + qDebug("KLibLoader::library could not find library: %s", libname.data()); + } else self()->d->errorMessage = QString::null; } return libfile; } KLibrary* KLibLoader::globalLibrary( const char *name ) { KLibrary *tmp; /*US int olt_dlopen_flag = lt_dlopen_flag; lt_dlopen_flag |= LT_GLOBAL; kdDebug(150) << "Loading the next library global with flag " << lt_dlopen_flag << "." << endl; */ tmp = library(name); /*US lt_dlopen_flag = olt_dlopen_flag; */ return tmp; } KLibrary* KLibLoader::library( const char *name ) { if (!name) return 0; KLibWrapPrivate* wrap = m_libs[name]; if (wrap) { /* Nothing to do to load the library. */ wrap->ref_count++; return wrap->lib; } /* Test if this library was loaded at some time, but got unloaded meanwhile, whithout being dlclose()'ed. */ QPtrListIterator<KLibWrapPrivate> it(d->loaded_stack); for (; it.current(); ++it) { if (it.current()->name == name) wrap = it.current(); } if (wrap) { d->pending_close.removeRef(wrap); if (!wrap->lib) { /* This lib only was in loaded_stack, but not in m_libs. */ wrap->lib = new KLibrary( name, wrap->filename, wrap->handle ); } wrap->ref_count++; } else { QString libfile = findLibrary( name ); if ( libfile.isEmpty() ) return 0; - const QString & qpeDir = QPEApplication::qpeDir(); - libfile = qpeDir + libfile; -//US QLibrary *lib = new QLibrary( qpeDir + "/plugins/korganizer/libopiekabc.so", QLibrary::Immediately ); QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately ); //US lt_dlhandle handle = lt_dlopen( libfile.latin1() ); //US if ( !handle ) if ( !qlib ) { //US const char* errmsg = lt_dlerror(); char* errmsg; sprintf(errmsg, "KLibLoader::library could not load library: %s", libfile.latin1()); qDebug(errmsg); if(errmsg) d->errorMessage = QString::fromLatin1(errmsg); else d->errorMessage = QString::null; kdWarning(150) << "library=" << name << ": file=" << libfile << ": " << d->errorMessage << endl; return 0; } else d->errorMessage = QString::null; KLibrary *lib = new KLibrary( name, libfile, qlib ); wrap = new KLibWrapPrivate(lib, qlib); d->loaded_stack.prepend(wrap); } m_libs.insert( name, wrap ); connect( wrap->lib, SIGNAL( destroyed() ), this, SLOT( slotLibraryDestroyed() ) ); return wrap->lib; } |