Bug 363634 - KF5 fails to load Windows executables located in the application bin directory
Summary: KF5 fails to load Windows executables located in the application bin directory
Status: RESOLVED WORKSFORME
Alias: None
Product: frameworks-kinit
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Microsoft Windows Microsoft Windows
: NOR major
Target Milestone: ---
Assignee: Hannah von Reth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-28 17:08 UTC by Jasem Mutlaq
Modified: 2016-08-25 08:50 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jasem Mutlaq 2016-05-28 17:08:16 UTC
When using emerge under Windows, it bundles all the executables & DLLs of the application and its dependencies in the bin directory of the application. When using emerge --package application, the same image is bundled using the NSIS installer. 

In several places (for example in kdeinitinterface.cpp, part of KDBusAddons), we have this:

QString srv = QStandardPaths::findExecutable(QStringLiteral("kdeinit5"));

However, under Windows, Qt only searches the executable in the system $PATH, and not the path from which the application is running. Even though kdeinit5.exe is located in the same bin directory as the running application, the above return an empty string because the current application bin directory is not part of the system path.

A solution to this issue is simply to search first in the current path, so the code becomes:

QString srv;
#ifdef Q_OS_WIN
srv = QStandardPaths::findExecutable(QStringLiteral("kdeinit5"), QStringList() << QCoreApplication::applicationDirPath());
#endif

if (srv.isEmpty())
srv = QStandardPaths::findExecutable(QStringLiteral("kdeinit5")); 

But this code only solves the problem for this instance, there are other places in the KDE frameworks that need to address this issue of finding and locating executable files under Windows.

Reproducible: Always

Steps to Reproduce:
1. See details
2.
3.

Actual Results:  
See Details

Expected Results:  
See Details
Comment 1 Jasem Mutlaq 2016-05-28 17:43:36 UTC
Followup. This is how Qt find the executables:

https://github.com/RSATom/Qt/blob/master/qtbase/src/corelib/io/qstandardpaths.cpp#L518

Specifically, it just uses:

QByteArray pEnv = qgetenv("PATH");

In emerge/portage, there is already a 20130714.patch file which modifies QStandardPaths to include unix-type location (.e.g share) on Windows,  but it doesn't address the executable issue. Perhaps it should be patched as well so that if searches inside the application's own directory first?