summaryrefslogtreecommitdiff
path: root/qmake/tools/qcomlibrary.cpp
Unidiff
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 @@
42#include <qdatetime.h> 42#include <qdatetime.h>
43#include <qcleanuphandler.h> 43#include <qcleanuphandler.h>
44#include <errno.h> 44#include <errno.h>
45 45
46#ifdef QT_THREAD_SUPPORT 46#ifdef QT_THREAD_SUPPORT
47# include "qmutexpool_p.h" 47# include "qmutexpool_p.h"
48#endif // QT_THREAD_SUPPORT 48#endif // QT_THREAD_SUPPORT
49 49
50#ifndef QT_DEBUG_COMPONENT 50#ifndef QT_DEBUG_COMPONENT
51# if defined(QT_DEBUG) 51# if defined(QT_DEBUG)
52# define QT_DEBUG_COMPONENT 1 52# define QT_DEBUG_COMPONENT 1
53# endif 53# endif
54#endif 54#endif
55 55
56 56
57QComLibrary::QComLibrary( const QString &filename ) 57QComLibrary::QComLibrary( const QString &filename )
58 : QLibrary( filename ), entry( 0 ), libiface( 0 ), qt_version( 0 ) 58 : QLibrary( filename ), entry( 0 ), libiface( 0 ), qt_version( 0 )
59{ 59{
60} 60}
61 61
62QComLibrary::~QComLibrary() 62QComLibrary::~QComLibrary()
63{ 63{
64 if ( autoUnload() ) 64 if ( autoUnload() )
65 unload(); 65 unload();
66 if ( libiface )
67 libiface->release();
68 if ( entry )
69 entry->release();
66} 70}
67 71
68bool QComLibrary::unload() 72bool QComLibrary::unload()
69{ 73{
70 if ( libiface ) { 74 if ( libiface ) {
71 libiface->cleanup(); 75 libiface->cleanup();
72 if ( !libiface->canUnload() ) 76 if ( !libiface->canUnload() )
73 return FALSE; 77 return FALSE;
74 libiface->release(); 78 libiface->release();
75 libiface = 0; 79 libiface = 0;
76 } 80 }
77 int refs = entry ? entry->release() : 0; 81 int refs = entry ? entry->release() : 0;
78 if ( refs ) 82 if ( refs )
79 return FALSE; 83 return FALSE;
80 84
81 entry = 0; 85 entry = 0;
82 86
83 return QLibrary::unload(); 87 return QLibrary::unload();
84} 88}
85 89
86static bool qt_verify( const QString& library, uint version, uint flags, 90static bool qt_verify( const QString& library, uint version, uint flags,
87 const QCString &key, bool warn ) 91 const QCString &key, bool warn )
88{ 92{
89 uint our_flags = 1; 93 uint our_flags = 1;
@@ -370,123 +374,116 @@ static bool qt_unix_query( const QString &library, uint *version, uint *flags,
370 374
371#endif // Q_OS_UNIX 375#endif // Q_OS_UNIX
372 376
373 377
374static QSettings *cache = 0; 378static QSettings *cache = 0;
375static QSingleCleanupHandler<QSettings> cleanup_cache; 379static QSingleCleanupHandler<QSettings> cleanup_cache;
376 380
377void QComLibrary::createInstanceInternal() 381void QComLibrary::createInstanceInternal()
378{ 382{
379 if ( library().isEmpty() ) 383 if ( library().isEmpty() )
380 return; 384 return;
381 385
382 QFileInfo fileinfo( library() ); 386 QFileInfo fileinfo( library() );
383 QString lastModified = fileinfo.lastModified().toString(); 387 QString lastModified = fileinfo.lastModified().toString();
384 QString regkey = QString("/Qt Plugins %1.%2/%3") 388 QString regkey = QString("/Qt Plugins %1.%2/%3")
385 .arg( ( QT_VERSION & 0xff0000 ) >> 16 ) 389 .arg( ( QT_VERSION & 0xff0000 ) >> 16 )
386 .arg( ( QT_VERSION & 0xff00 ) >> 8 ) 390 .arg( ( QT_VERSION & 0xff00 ) >> 8 )
387 .arg( library() ); 391 .arg( library() );
388 QStringList reg; 392 QStringList reg;
389 uint flags = 0; 393 uint flags = 0;
390 QCString key; 394 QCString key;
391 bool query_done = FALSE; 395 bool query_done = FALSE;
392 bool warn_mismatch = TRUE; 396 bool warn_mismatch = TRUE;
393 397
394 if ( ! query_done ) {
395
396#ifdef QT_THREAD_SUPPORT 398#ifdef QT_THREAD_SUPPORT
397 QMutexLocker locker( qt_global_mutexpool->get( &cache ) ); 399 QMutexLocker locker( qt_global_mutexpool ?
400 qt_global_mutexpool->get( &cache ) : 0 );
398#endif // QT_THREAD_SUPPORT 401#endif // QT_THREAD_SUPPORT
399 402
400 if ( ! cache ) { 403 if ( ! cache ) {
401 cache = new QSettings; 404 cache = new QSettings;
402 cache->insertSearchPath( QSettings::Windows, "/Trolltech" ); 405 cache->insertSearchPath( QSettings::Windows, "/Trolltech" );
403 cleanup_cache.set( &cache ); 406 cleanup_cache.set( &cache );
404 } 407 }
405 408
406 reg = cache->readListEntry( regkey ); 409 reg = cache->readListEntry( regkey );
407 if ( reg.count() == 4 ) { 410 if ( reg.count() == 4 ) {
408 // check timestamp 411 // check timestamp
409 if ( lastModified == reg[3] ) { 412 if ( lastModified == reg[3] ) {
410 qt_version = reg[0].toUInt(0, 16); 413 qt_version = reg[0].toUInt(0, 16);
411 flags = reg[1].toUInt(0, 16); 414 flags = reg[1].toUInt(0, 16);
412 key = reg[2].latin1(); 415 key = reg[2].latin1();
413 416
414 query_done = TRUE; 417 query_done = TRUE;
415 warn_mismatch = FALSE; 418 warn_mismatch = FALSE;
416 }
417 } 419 }
418 } 420 }
419 421
420#if defined(Q_OS_UNIX) 422#if defined(Q_OS_UNIX)
421 if ( ! query_done ) { 423 if ( ! query_done ) {
422 // get the query information directly from the plugin without loading 424 // get the query information directly from the plugin without loading
423 if ( qt_unix_query( library(), &qt_version, &flags, &key ) ) { 425 if ( qt_unix_query( library(), &qt_version, &flags, &key ) ) {
424 // info read succesfully from library 426 // info read succesfully from library
425 query_done = TRUE; 427 query_done = TRUE;
426 } 428 }
427 } 429 }
428#else // !Q_OS_UNIX 430#else // !Q_OS_UNIX
429 if ( ! query_done ) { 431 if ( ! query_done ) {
430 // get the query information by loading the plugin 432 // get the query information by loading the plugin
431 if ( !isLoaded() ) { 433 if ( !isLoaded() ) {
432 Q_ASSERT( entry == 0 ); 434 Q_ASSERT( entry == 0 );
433 if ( !load() ) 435 if ( !load() )
434 return; 436 return;
435 } 437 }
436 438
437# ifdef Q_CC_BOR 439# ifdef Q_CC_BOR
438 typedef const char * __stdcall (*UCMQueryVerificationDataProc)(); 440 typedef const char * __stdcall (*UCMQueryVerificationDataProc)();
439# else 441# else
440 typedef const char * (*UCMQueryVerificationDataProc)(); 442 typedef const char * (*UCMQueryVerificationDataProc)();
441# endif 443# endif
442 UCMQueryVerificationDataProc ucmQueryVerificationdataProc; 444 UCMQueryVerificationDataProc ucmQueryVerificationdataProc;
443 ucmQueryVerificationdataProc = 445 ucmQueryVerificationdataProc =
444 (UCMQueryVerificationDataProc) resolve( "qt_ucm_query_verification_data" ); 446 (UCMQueryVerificationDataProc) resolve( "qt_ucm_query_verification_data" );
445 447
446 if ( !ucmQueryVerificationdataProc || 448 if ( !ucmQueryVerificationdataProc ||
447 !qt_parse_pattern( ucmQueryVerificationdataProc(), 449 !qt_parse_pattern( ucmQueryVerificationdataProc(),
448 &qt_version, &flags, &key ) ) { 450 &qt_version, &flags, &key ) ) {
449 qt_version = flags = 0; 451 qt_version = flags = 0;
450 key = "unknown"; 452 key = "unknown";
451 } else { 453 } else {
452 query_done = TRUE; 454 query_done = TRUE;
453 } 455 }
454 } 456 }
455#endif // Q_OS_UNIX 457#endif // Q_OS_UNIX
456 458
457 QStringList queried; 459 QStringList queried;
458 queried << QString::number( qt_version,16 ) 460 queried << QString::number( qt_version,16 )
459 << QString::number( flags, 16 ) 461 << QString::number( flags, 16 )
460 << key 462 << key
461 << lastModified; 463 << lastModified;
462 464
463 if ( queried != reg ) { 465 if ( queried != reg ) {
464
465#ifdef QT_THREAD_SUPPORT
466 QMutexLocker locker( qt_global_mutexpool->get( &cache ) );
467#endif // QT_THREAD_SUPPORT
468
469 cache->writeEntry( regkey, queried ); 466 cache->writeEntry( regkey, queried );
470 // delete the cache, which forces the settings to be written 467 // delete the cache, which forces the settings to be written
471 delete cache; 468 delete cache;
472 cache = 0; 469 cache = 0;
473 } 470 }
474 471
475 if ( ! query_done ) { 472 if ( ! query_done ) {
476 if ( warn_mismatch ) { 473 if ( warn_mismatch ) {
477 qWarning( "Conflict in %s:\n Plugin cannot be queried successfully!", 474 qWarning( "Conflict in %s:\n Plugin cannot be queried successfully!",
478 (const char*) QFile::encodeName( library() ) ); 475 (const char*) QFile::encodeName( library() ) );
479 } 476 }
480 unload(); 477 unload();
481 return; 478 return;
482 } 479 }
483 480
484 if ( ! qt_verify( library(), qt_version, flags, key, warn_mismatch ) ) { 481 if ( ! qt_verify( library(), qt_version, flags, key, warn_mismatch ) ) {
485 unload(); 482 unload();
486 return; 483 return;
487 } else if ( !isLoaded() ) { 484 } else if ( !isLoaded() ) {
488 Q_ASSERT( entry == 0 ); 485 Q_ASSERT( entry == 0 );
489 if ( !load() ) 486 if ( !load() )
490 return; 487 return;
491 } 488 }
492 489