summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin/qlibrary.cpp
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2012-07-18 13:12:46 +0100
committerQt by Nokia <qt-info@nokia.com>2012-07-23 17:56:13 +0200
commit0026b80cd2a484ad9d685ff5a4f89e6c9815f913 (patch)
treeb62c9edd46c777e24aedfe2b8b7a2b46594e2f5c /src/corelib/plugin/qlibrary.cpp
parentb1829403408aebdf62b61dcefdb96b0457b9bd3e (diff)
Improve the loading performance of QLibrary
If an absolute path is specified we try that first. Otherwise we first try the most likely system-specific format (e.g. libfoo.so) on Unix. This improves performance especially on systems with slow flash devices. For example, prior to this commit loading the Xcursor library (in the xcb plugin) results in attempts to dlopen: "Xcursor" "Xcursor.so.1" "libXcursor" "libXcursor.so.1" With this commit this is reduced to a single attempt of: "libXcursor.so.1" Plugin loading uses absolute paths with QLibrary so there is no performance penalty for plugins with this commit. This is however a behavioural change with respect to Qt4 but one that I believe is justified and wanted. Change-Id: I7813afa335f9bf515e87934c2f8f97888818c69c Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/corelib/plugin/qlibrary.cpp')
-rw-r--r--src/corelib/plugin/qlibrary.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 8e69960c93..3815082989 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -96,13 +96,22 @@ static QBasicMutex qt_library_mutex;
name in the constructor, or set it explicitly with setFileName().
When loading the library, QLibrary searches in all the
system-specific library locations (e.g. \c LD_LIBRARY_PATH on
- Unix), unless the file name has an absolute path. If the file
- cannot be found, QLibrary tries the name with different
- platform-specific file suffixes, like ".so" on Unix, ".dylib" on
- the Mac, or ".dll" on Windows. This makes it possible
- to specify shared libraries that are only identified by their
- basename (i.e. without their suffix), so the same code will work
- on different operating systems.
+ Unix), unless the file name has an absolute path.
+
+ If the file name is an absolute path then an attempt is made to
+ load this path first. If the file cannot be found, QLibrary tries
+ the name with different platform-specific file prefixes, like
+ "lib" on Unix and Mac, and suffixes, like ".so" on Unix, ".dylib"
+ on the Mac, or ".dll" on Windows.
+
+ If the file path is not absolute then QLibrary modifies the search
+ order to try the system-specific prefixes and suffixes first,
+ followed by the file path specified.
+
+ This makes it possible to specify shared libraries that are only
+ identified by their basename (i.e. without their suffix), so the
+ same code will work on different operating systems yet still
+ minimise the number of attempts to find the library.
The most important functions are load() to dynamically load the
library file, isLoaded() to check whether loading was successful,