-rw-r--r-- | qmake/tools/qlibrary.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/qmake/tools/qlibrary.cpp b/qmake/tools/qlibrary.cpp index 564db30..be1d54b 100644 --- a/qmake/tools/qlibrary.cpp +++ b/qmake/tools/qlibrary.cpp | |||
@@ -1,32 +1,32 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Implementation of QLibrary class | 4 | ** Implementation of QLibrary class |
5 | ** | 5 | ** |
6 | ** Created : 2000-01-01 | 6 | ** Created : 000101 |
7 | ** | 7 | ** |
8 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 8 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. |
9 | ** | 9 | ** |
10 | ** This file is part of the tools module of the Qt GUI Toolkit. | 10 | ** This file is part of the tools module of the Qt GUI Toolkit. |
11 | ** | 11 | ** |
12 | ** This file may be distributed under the terms of the Q Public License | 12 | ** This file may be distributed under the terms of the Q Public License |
13 | ** as defined by Trolltech AS of Norway and appearing in the file | 13 | ** as defined by Trolltech AS of Norway and appearing in the file |
14 | ** LICENSE.QPL included in the packaging of this file. | 14 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 15 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 16 | ** This file may be distributed and/or modified under the terms of the |
17 | ** GNU General Public License version 2 as published by the Free Software | 17 | ** GNU General Public License version 2 as published by the Free Software |
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 18 | ** Foundation and appearing in the file LICENSE.GPL included in the |
19 | ** packaging of this file. | 19 | ** packaging of this file. |
20 | ** | 20 | ** |
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition |
22 | ** licenses may use this file in accordance with the Qt Commercial License | 22 | ** licenses may use this file in accordance with the Qt Commercial License |
23 | ** Agreement provided with the Software. | 23 | ** Agreement provided with the Software. |
24 | ** | 24 | ** |
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
27 | ** | 27 | ** |
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
29 | ** information about Qt Commercial License Agreements. | 29 | ** information about Qt Commercial License Agreements. |
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
32 | ** | 32 | ** |
@@ -50,49 +50,49 @@ | |||
50 | # define QT_DEBUG_COMPONENT 1 | 50 | # define QT_DEBUG_COMPONENT 1 |
51 | # endif | 51 | # endif |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #if defined(QT_DEBUG_COMPONENT) | 54 | #if defined(QT_DEBUG_COMPONENT) |
55 | #include <qfile.h> | 55 | #include <qfile.h> |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #if defined(Q_WS_WIN) && !defined(QT_MAKEDLL) | 58 | #if defined(Q_WS_WIN) && !defined(QT_MAKEDLL) |
59 | #define QT_NO_LIBRARY_UNLOAD | 59 | #define QT_NO_LIBRARY_UNLOAD |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | QLibraryPrivate::QLibraryPrivate( QLibrary *lib ) | 62 | QLibraryPrivate::QLibraryPrivate( QLibrary *lib ) |
63 | : pHnd( 0 ), library( lib ) | 63 | : pHnd( 0 ), library( lib ) |
64 | { | 64 | { |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | /*! | 68 | /*! |
69 | \class QLibrary qlibrary.h | 69 | \class QLibrary qlibrary.h |
70 | \reentrant | 70 | \reentrant |
71 | \brief The QLibrary class provides a wrapper for handling shared libraries. | 71 | \brief The QLibrary class provides a wrapper for handling shared libraries. |
72 | 72 | ||
73 | \mainclass | 73 | \mainclass |
74 | \group plugins | 74 | \ingroup plugins |
75 | 75 | ||
76 | An instance of a QLibrary object can handle a single shared | 76 | An instance of a QLibrary object can handle a single shared |
77 | library and provide access to the functionality in the library in | 77 | library and provide access to the functionality in the library in |
78 | a platform independent way. If the library is a component server, | 78 | a platform independent way. If the library is a component server, |
79 | QLibrary provides access to the exported component and can | 79 | QLibrary provides access to the exported component and can |
80 | directly query this component for interfaces. | 80 | directly query this component for interfaces. |
81 | 81 | ||
82 | QLibrary ensures that the shared library is loaded and stays in | 82 | QLibrary ensures that the shared library is loaded and stays in |
83 | memory whilst it is in use. QLibrary can also unload the library | 83 | memory whilst it is in use. QLibrary can also unload the library |
84 | on destruction and release unused resources. | 84 | on destruction and release unused resources. |
85 | 85 | ||
86 | A typical use of QLibrary is to resolve an exported symbol in a | 86 | A typical use of QLibrary is to resolve an exported symbol in a |
87 | shared object, and to call the function that this symbol | 87 | shared object, and to call the function that this symbol |
88 | represents. This is called "explicit linking" in contrast to | 88 | represents. This is called "explicit linking" in contrast to |
89 | "implicit linking", which is done by the link step in the build | 89 | "implicit linking", which is done by the link step in the build |
90 | process when linking an executable against a library. | 90 | process when linking an executable against a library. |
91 | 91 | ||
92 | The following code snippet loads a library, resolves the symbol | 92 | The following code snippet loads a library, resolves the symbol |
93 | "mysymbol", and calls the function if everything succeeded. If | 93 | "mysymbol", and calls the function if everything succeeded. If |
94 | something went wrong, e.g. the library file does not exist or the | 94 | something went wrong, e.g. the library file does not exist or the |
95 | symbol is not defined, the function pointer will be 0 and won't be | 95 | symbol is not defined, the function pointer will be 0 and won't be |
96 | called. When the QLibrary object is destroyed the library will be | 96 | called. When the QLibrary object is destroyed the library will be |
97 | unloaded, making all references to memory allocated in the library | 97 | unloaded, making all references to memory allocated in the library |
98 | invalid. | 98 | invalid. |
@@ -305,39 +305,40 @@ void QLibrary::setAutoUnload( bool enabled ) | |||
305 | Returns the filename of the shared library this QLibrary object | 305 | Returns the filename of the shared library this QLibrary object |
306 | handles, including the platform specific file extension. | 306 | handles, including the platform specific file extension. |
307 | 307 | ||
308 | For example: | 308 | For example: |
309 | \code | 309 | \code |
310 | QLibrary lib( "mylib" ); | 310 | QLibrary lib( "mylib" ); |
311 | QString str = lib.library(); | 311 | QString str = lib.library(); |
312 | \endcode | 312 | \endcode |
313 | will set \e str to "mylib.dll" on Windows, and "libmylib.so" on Linux. | 313 | will set \e str to "mylib.dll" on Windows, and "libmylib.so" on Linux. |
314 | */ | 314 | */ |
315 | QString QLibrary::library() const | 315 | QString QLibrary::library() const |
316 | { | 316 | { |
317 | if ( libfile.isEmpty() ) | 317 | if ( libfile.isEmpty() ) |
318 | return libfile; | 318 | return libfile; |
319 | 319 | ||
320 | QString filename = libfile; | 320 | QString filename = libfile; |
321 | 321 | ||
322 | #if defined(Q_WS_WIN) | 322 | #if defined(Q_WS_WIN) |
323 | if ( filename.findRev( '.' ) <= filename.findRev( '/' ) ) | 323 | if ( filename.findRev( '.' ) <= filename.findRev( '/' ) ) |
324 | filename += ".dll"; | 324 | filename += ".dll"; |
325 | #elif defined(Q_OS_MACX) | 325 | #elif defined(Q_OS_MACX) |
326 | if ( filename.find( ".dylib" ) == -1 ) | 326 | if ( filename.find( ".dylib" ) == -1 ) |
327 | filename += ".dylib"; | 327 | filename += ".dylib"; |
328 | #else | 328 | #else |
329 | if ( filename.find( ".so" ) == -1 ) { | 329 | QString filter = ".so"; |
330 | if ( filename.find(filter) == -1 ) { | ||
330 | const int x = filename.findRev( "/" ); | 331 | const int x = filename.findRev( "/" ); |
331 | if ( x != -1 ) { | 332 | if ( x != -1 ) { |
332 | QString path = filename.left( x + 1 ); | 333 | QString path = filename.left( x + 1 ); |
333 | QString file = filename.right( filename.length() - x - 1 ); | 334 | QString file = filename.right( filename.length() - x - 1 ); |
334 | filename = QString( "%1lib%2.so" ).arg( path ).arg( file ); | 335 | filename = QString( "%1lib%2.%3" ).arg( path ).arg( file ).arg( filter ); |
335 | } else { | 336 | } else { |
336 | filename = QString( "lib%1.so" ).arg( filename ); | 337 | filename = QString( "lib%1.%2" ).arg( filename ).arg( filter ); |
337 | } | 338 | } |
338 | } | 339 | } |
339 | #endif | 340 | #endif |
340 | 341 | ||
341 | return filename; | 342 | return filename; |
342 | } | 343 | } |
343 | #endif //QT_NO_LIBRARY | 344 | #endif //QT_NO_LIBRARY |