From 4fe71db2ee0db2eab3d1927a1904635a3d26970f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 3 Nov 2021 22:25:11 -0700 Subject: [PATCH] QCoreApplication: document the app's bindir is in libraryPaths() The QCoreApplicationPrivate::appendApplicationPathToLibraryPaths() function has been there since at least Qt 4.5.1, so the documentation for appendLibraryPaths() hasn't matched behavior for a minimum of 13 years. The documentation for libraryPaths() has mentioned this fact, though. Searching the application's bin dir is normal on Windows, as many application packages are a flat install with the .exe and all .dlls in one dir. I find it questionable to do so on Unix, though: any and all applications expecting to be installed by a Linux distribution would not install plugins to /usr/bin, whereas on macOS bundles have their own organization anyway. But I'm not prepared to change the behavior without more justification. I can think only of broken configurations (such what is described in QTBUG-97950 where a combination of bad decisions led to scanning all of /usr/bin) and running an executable that is stored in a world-writable directory. Task-number: QTBUG-97950 Pick-to: 6.2 Change-Id: Ice04365c72984d07a64dfffd16b440868373d7a5 Reviewed-by: Ulf Hermann --- src/corelib/kernel/qcoreapplication.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index e3530a3393f..ff23623e9a0 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2837,10 +2837,11 @@ void QCoreApplication::setLibraryPaths(const QStringList &paths) it is searched for libraries first. If \a path is empty or already in the path list, the path list is not changed. - The default path list consists of a single entry, the installation - directory for plugins. The default installation directory for plugins - is \c INSTALL/plugins, where \c INSTALL is the directory where Qt was - installed. + The default path list consists of one or two entries. The first is the + installation directory for plugins, which is \c INSTALL/plugins, where \c + INSTALL is the directory where Qt was installed. The second is the + application's own directory (\b not the current directory), but only after + the QCoreApplication object is instantiated. The library paths are reset to the default when an instance of QCoreApplication is destructed.