summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libs/utils/winutils.cpp44
-rw-r--r--src/libs/utils/winutils.h6
-rw-r--r--src/plugins/projectexplorer/applicationlauncher_win.cpp6
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp5
4 files changed, 12 insertions, 49 deletions
diff --git a/src/libs/utils/winutils.cpp b/src/libs/utils/winutils.cpp
index 80ea37134b..2c4bb30de6 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 b32c88c86d..817717d39a 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 d383ec9e0a..56c53ed20f 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 e51367318e..6106a975ed 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