diff --git a/src/libs/utils/winutils.cpp b/src/libs/utils/winutils.cpp index 80ea37134b8d67ee174491a0b18fee3c28417ea9..2c4bb30de6626c7f7de4fdb734b87fb845b351a7 100644 --- a/src/libs/utils/winutils.cpp +++ b/src/libs/utils/winutils.cpp @@ -132,66 +132,34 @@ QTCREATOR_UTILS_EXPORT QString winGetDLLVersion(WinDLLVersionType t, return rc; } -QTCREATOR_UTILS_EXPORT QString getShortPathName(const QString &name, QString *errorMessage) +QTCREATOR_UTILS_EXPORT QString getShortPathName(const QString &name) { - typedef DWORD (APIENTRY *GetShortPathNameProtoType)(LPCTSTR, LPTSTR, DWORD); - if (name.isEmpty()) return name; - const char *kernel32DLLC = "kernel32.dll"; - - QLibrary kernel32Lib(kernel32DLLC, 0); - if (!kernel32Lib.isLoaded() && !kernel32Lib.load()) { - *errorMessage = msgCannotLoad(kernel32DLLC, kernel32Lib.errorString()); - return QString(); - } - - // MinGW requires old-style casts - GetShortPathNameProtoType getShortPathNameW = (GetShortPathNameProtoType)(kernel32Lib.resolve("GetShortPathNameW")); - if (!getShortPathNameW) { - *errorMessage = msgCannotResolve(kernel32DLLC); - return QString(); - } // Determine length, then convert. const LPCTSTR nameC = reinterpret_cast<LPCTSTR>(name.utf16()); // MinGW - const DWORD length = (*getShortPathNameW)(nameC, NULL, 0); + const DWORD length = GetShortPathNameW(nameC, NULL, 0); if (length == 0) return name; QScopedArrayPointer<TCHAR> buffer(new TCHAR[length]); - (*getShortPathNameW)(nameC, buffer.data(), length); + GetShortPathNameW(nameC, buffer.data(), length); const QString rc = QString::fromUtf16(reinterpret_cast<const ushort *>(buffer.data()), length - 1); return rc; } -QTCREATOR_UTILS_EXPORT QString getLongPathName(const QString &name, QString *errorMessage) +QTCREATOR_UTILS_EXPORT QString getLongPathName(const QString &name) { - typedef DWORD (APIENTRY *GetLongPathNameProtoType)(LPCTSTR, LPTSTR, DWORD); - if (name.isEmpty()) return name; - const char *kernel32DLLC = "kernel32.dll"; - - QLibrary kernel32Lib(kernel32DLLC, 0); - if (!kernel32Lib.isLoaded() && !kernel32Lib.load()) { - *errorMessage = msgCannotLoad(kernel32DLLC, kernel32Lib.errorString()); - return QString(); - } - - // MinGW requires old-style casts - GetLongPathNameProtoType getLongPathNameW = (GetLongPathNameProtoType)(kernel32Lib.resolve("GetLongPathNameW")); - if (!getLongPathNameW) { - *errorMessage = msgCannotResolve(kernel32DLLC); - return QString(); - } // Determine length, then convert. const LPCTSTR nameC = reinterpret_cast<LPCTSTR>(name.utf16()); // MinGW - const DWORD length = (*getLongPathNameW)(nameC, NULL, 0); + const DWORD length = GetLongPathNameW(nameC, NULL, 0); if (length == 0) return name; QScopedArrayPointer<TCHAR> buffer(new TCHAR[length]); - (*getLongPathNameW)(nameC, buffer.data(), length); + GetLongPathNameW(nameC, buffer.data(), length); const QString rc = QString::fromUtf16(reinterpret_cast<const ushort *>(buffer.data()), length - 1); return rc; } diff --git a/src/libs/utils/winutils.h b/src/libs/utils/winutils.h index b32c88c86d16efef3eeea42f6cbcdc6d31dc35ec..817717d39a92a437025f6aa7baa6024503d4855a 100644 --- a/src/libs/utils/winutils.h +++ b/src/libs/utils/winutils.h @@ -55,12 +55,10 @@ QTCREATOR_UTILS_EXPORT QString winGetDLLVersion(WinDLLVersionType t, QString *errorMessage); // Return the short (8.3) file name -QTCREATOR_UTILS_EXPORT QString getShortPathName(const QString &name, - QString *errorMessage); +QTCREATOR_UTILS_EXPORT QString getShortPathName(const QString &name); // Returns long name -QTCREATOR_UTILS_EXPORT QString getLongPathName(const QString &name, - QString *errorMessage); +QTCREATOR_UTILS_EXPORT QString getLongPathName(const QString &name); QTCREATOR_UTILS_EXPORT unsigned long winQPidToPid(const Q_PID qpid); diff --git a/src/plugins/projectexplorer/applicationlauncher_win.cpp b/src/plugins/projectexplorer/applicationlauncher_win.cpp index d383ec9e0a15b8a95aeb183b06b1ba51554605c7..56c53ed20fc4994c40538ed29954f062a136c8af 100644 --- a/src/plugins/projectexplorer/applicationlauncher_win.cpp +++ b/src/plugins/projectexplorer/applicationlauncher_win.cpp @@ -71,11 +71,9 @@ ApplicationLauncher::~ApplicationLauncher() void ApplicationLauncher::setWorkingDirectory(const QString &dir) { - QString fixedPath = dir; - QString error; - // Work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch' ...) - const QString longPath = Utils::getLongPathName(dir, &error); + QString fixedPath = dir; + const QString longPath = Utils::getLongPathName(dir); if (!longPath.isEmpty()) fixedPath = longPath; diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index e51367318eaa2d0a52e58dc2c9127130eaec6a1c..6106a975ed7dce6ebabed2b33919cc304b2279b1 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -188,12 +188,11 @@ QString QmlProjectRunConfiguration::canonicalCapsPath(const QString &fileName) QString canonicalPath = QFileInfo(fileName).canonicalFilePath(); #if defined(Q_OS_WIN32) - QString error; // don't know whether the shortpath step is really needed, // but we do this in QtDeclarative too. - QString path = Utils::getShortPathName(canonicalPath, &error); + QString path = Utils::getShortPathName(canonicalPath); if (!path.isEmpty()) - path = Utils::getLongPathName(canonicalPath, &error); + path = Utils::getLongPathName(canonicalPath); if (!path.isEmpty()) canonicalPath = path; #endif