-rw-r--r-- | library/qlibrary.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/qlibrary.cpp b/library/qlibrary.cpp index 4aabbc5..cbf49a3 100644 --- a/library/qlibrary.cpp +++ b/library/qlibrary.cpp @@ -1,196 +1,196 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "qlibrary_p.h" // uncomment this to get error messages //#define QT_DEBUG_COMPONENT 1 // uncomment this to get error and success messages //#define QT_DEBUG_COMPONENT 2 #ifndef QT_DEBUG_COMPONENT # if defined(QT_DEBUG) # define QT_DEBUG_COMPONENT 1 # endif #endif #ifndef QT_NO_COMPONENT // KAI C++ has at the moment problems with unloading the Qt plugins. So don't // unload them as a workaround for now. #if defined(Q_CC_KAI) || defined(Q_OS_MAC) #define QT_NO_LIBRARY_UNLOAD #endif #if defined(Q_WS_WIN) && !defined(QT_MAKEDLL) #define QT_NO_LIBRARY_UNLOAD #endif /* Platform independent QLibraryPrivate implementations */ #ifndef QT_LITE_COMPONENT #include "qtimer.h" extern Q_EXPORT QApplication *qApp; QLibraryPrivate::QLibraryPrivate( QLibrary *lib ) : QObject( 0, lib->library().latin1() ), pHnd( 0 ), libIface( 0 ), unloadTimer( 0 ), library( lib ) { } QLibraryPrivate::~QLibraryPrivate() { if ( libIface ) libIface->release(); killTimer(); } /* Only components that implement the QLibraryInterface can be unloaded automatically. */ void QLibraryPrivate::tryUnload() { if ( library->policy() == QLibrary::Manual || !pHnd || !libIface ) return; if ( !libIface->canUnload() ) return; #if defined(QT_DEBUG_COMPONENT) && QT_DEBUG_COMPONENT == 2 if ( library->unload() ) qDebug( "%s has been automatically unloaded", library->library().latin1() ); #else library->unload(); #endif } #else // QT_LITE_COMPOINENT QLibraryPrivate::QLibraryPrivate( QLibrary *lib ) : pHnd( 0 ), libIface( 0 ), library( lib ) { } #endif // QT_LITE_COMPOINENT void QLibraryPrivate::startTimer() { #ifndef QT_LITE_COMPONENT unloadTimer = new QTimer( this ); connect( unloadTimer, SIGNAL( timeout() ), this, SLOT( tryUnload() ) ); unloadTimer->start( 5000, FALSE ); #endif } void QLibraryPrivate::killTimer() { #ifndef QT_LITE_COMPONENT delete unloadTimer; unloadTimer = 0; #endif } /*! \class QLibrary qlibrary.h \brief The QLibrary class provides a wrapper for handling shared libraries. This class is temporarily copied from Qt 3.0. */ /*! \enum QLibrary::Policy This enum type defines the various policies a QLibrary can have with respect to loading and unloading the shared library. The \e policy can be: \value Delayed The library get's loaded as soon as needed and unloaded in the destructor \value Immediately The library is loaded immediately and unloaded in the destructor \value Manual Like delayed, and library has to be unloaded manually */ /*! Creates a QLibrary object for the shared library \a filename. The library get's loaded if \a pol is Immediately. Note that \a filename does not need to include the (platform specific) file extension, so calling \code QLibrary lib( "mylib" ); \endcode would be equivalent to \code QLibrary lib( "mylib.dll" ); \endcode on Windows. But \e "mylib.dll" will obviously not work on other platforms. \sa setPolicy(), unload() */ QLibrary::QLibrary( const QString& filename, Policy pol ) : libfile( filename ), libPol( pol ), entry( 0 ) { d = new QLibraryPrivate( this ); if ( pol == Immediately ) load(); } /*! Deletes the QLibrary object. The library will be unloaded if the policy is not Manual. \sa unload(), setPolicy() */ QLibrary::~QLibrary() { if ( libPol == Manual || !unload() ) { if ( entry ) { entry->release(); entry = 0; } } delete d; } void QLibrary::createInstanceInternal() { if ( libfile.isEmpty() ) return; if ( !d->pHnd ) { ASSERT( entry == 0 ); load(); } if ( d->pHnd && !entry ) { #if defined(QT_DEBUG_COMPONENT) && QT_DEBUG_COMPONENT == 2 qWarning( "%s has been loaded.", library().latin1() ); #endif typedef QUnknownInterface* (*UCMInstanceProc)(); UCMInstanceProc ucmInstanceProc; ucmInstanceProc = (UCMInstanceProc) resolve( "ucm_instantiate" ); entry = ucmInstanceProc ? ucmInstanceProc() : 0; |