summaryrefslogtreecommitdiff
path: root/qmake/tools/qcomlibrary.cpp
Side-by-side diff
Diffstat (limited to 'qmake/tools/qcomlibrary.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/tools/qcomlibrary.cpp43
1 files changed, 20 insertions, 23 deletions
diff --git a/qmake/tools/qcomlibrary.cpp b/qmake/tools/qcomlibrary.cpp
index a7162fc..2a1b75a 100644
--- a/qmake/tools/qcomlibrary.cpp
+++ b/qmake/tools/qcomlibrary.cpp
@@ -42,48 +42,52 @@
#include <qdatetime.h>
#include <qcleanuphandler.h>
#include <errno.h>
#ifdef QT_THREAD_SUPPORT
# include "qmutexpool_p.h"
#endif // QT_THREAD_SUPPORT
#ifndef QT_DEBUG_COMPONENT
# if defined(QT_DEBUG)
# define QT_DEBUG_COMPONENT 1
# endif
#endif
QComLibrary::QComLibrary( const QString &filename )
: QLibrary( filename ), entry( 0 ), libiface( 0 ), qt_version( 0 )
{
}
QComLibrary::~QComLibrary()
{
if ( autoUnload() )
unload();
+ if ( libiface )
+ libiface->release();
+ if ( entry )
+ entry->release();
}
bool QComLibrary::unload()
{
if ( libiface ) {
libiface->cleanup();
if ( !libiface->canUnload() )
return FALSE;
libiface->release();
libiface = 0;
}
int refs = entry ? entry->release() : 0;
if ( refs )
return FALSE;
entry = 0;
return QLibrary::unload();
}
static bool qt_verify( const QString& library, uint version, uint flags,
const QCString &key, bool warn )
{
uint our_flags = 1;
@@ -370,123 +374,116 @@ static bool qt_unix_query( const QString &library, uint *version, uint *flags,
#endif // Q_OS_UNIX
static QSettings *cache = 0;
static QSingleCleanupHandler<QSettings> cleanup_cache;
void QComLibrary::createInstanceInternal()
{
if ( library().isEmpty() )
return;
QFileInfo fileinfo( library() );
QString lastModified = fileinfo.lastModified().toString();
QString regkey = QString("/Qt Plugins %1.%2/%3")
.arg( ( QT_VERSION & 0xff0000 ) >> 16 )
.arg( ( QT_VERSION & 0xff00 ) >> 8 )
.arg( library() );
QStringList reg;
uint flags = 0;
QCString key;
bool query_done = FALSE;
bool warn_mismatch = TRUE;
- if ( ! query_done ) {
-
#ifdef QT_THREAD_SUPPORT
- QMutexLocker locker( qt_global_mutexpool->get( &cache ) );
+ QMutexLocker locker( qt_global_mutexpool ?
+ qt_global_mutexpool->get( &cache ) : 0 );
#endif // QT_THREAD_SUPPORT
- if ( ! cache ) {
- cache = new QSettings;
- cache->insertSearchPath( QSettings::Windows, "/Trolltech" );
- cleanup_cache.set( &cache );
- }
+ if ( ! cache ) {
+ cache = new QSettings;
+ cache->insertSearchPath( QSettings::Windows, "/Trolltech" );
+ cleanup_cache.set( &cache );
+ }
- reg = cache->readListEntry( regkey );
- if ( reg.count() == 4 ) {
- // check timestamp
- if ( lastModified == reg[3] ) {
- qt_version = reg[0].toUInt(0, 16);
- flags = reg[1].toUInt(0, 16);
- key = reg[2].latin1();
+ reg = cache->readListEntry( regkey );
+ if ( reg.count() == 4 ) {
+ // check timestamp
+ if ( lastModified == reg[3] ) {
+ qt_version = reg[0].toUInt(0, 16);
+ flags = reg[1].toUInt(0, 16);
+ key = reg[2].latin1();
- query_done = TRUE;
- warn_mismatch = FALSE;
- }
+ query_done = TRUE;
+ warn_mismatch = FALSE;
}
}
#if defined(Q_OS_UNIX)
if ( ! query_done ) {
// get the query information directly from the plugin without loading
if ( qt_unix_query( library(), &qt_version, &flags, &key ) ) {
// info read succesfully from library
query_done = TRUE;
}
}
#else // !Q_OS_UNIX
if ( ! query_done ) {
// get the query information by loading the plugin
if ( !isLoaded() ) {
Q_ASSERT( entry == 0 );
if ( !load() )
return;
}
# ifdef Q_CC_BOR
typedef const char * __stdcall (*UCMQueryVerificationDataProc)();
# else
typedef const char * (*UCMQueryVerificationDataProc)();
# endif
UCMQueryVerificationDataProc ucmQueryVerificationdataProc;
ucmQueryVerificationdataProc =
(UCMQueryVerificationDataProc) resolve( "qt_ucm_query_verification_data" );
if ( !ucmQueryVerificationdataProc ||
!qt_parse_pattern( ucmQueryVerificationdataProc(),
&qt_version, &flags, &key ) ) {
qt_version = flags = 0;
key = "unknown";
} else {
query_done = TRUE;
}
}
#endif // Q_OS_UNIX
QStringList queried;
queried << QString::number( qt_version,16 )
<< QString::number( flags, 16 )
<< key
<< lastModified;
if ( queried != reg ) {
-
-#ifdef QT_THREAD_SUPPORT
- QMutexLocker locker( qt_global_mutexpool->get( &cache ) );
-#endif // QT_THREAD_SUPPORT
-
cache->writeEntry( regkey, queried );
// delete the cache, which forces the settings to be written
delete cache;
cache = 0;
}
if ( ! query_done ) {
if ( warn_mismatch ) {
qWarning( "Conflict in %s:\n Plugin cannot be queried successfully!",
(const char*) QFile::encodeName( library() ) );
}
unload();
return;
}
if ( ! qt_verify( library(), qt_version, flags, key, warn_mismatch ) ) {
unload();
return;
} else if ( !isLoaded() ) {
Q_ASSERT( entry == 0 );
if ( !load() )
return;
}