Skip to content

Commit 2a41456

Browse files
committed
try to fix build on Mac
1 parent bd68cbb commit 2a41456

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/third_party/mimetypes-qt4/io/qstandardpaths_mac.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
#include "qstandardpaths.h"
4343
#include <QtCore/qdir.h>
44+
//#include <private/qcore_mac_p.h>
4445

4546
#ifndef QT_BOOTSTRAPPED
4647
#include <QtCore/qcoreapplication.h>
@@ -186,6 +187,20 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
186187
return dirs;
187188
}
188189

190+
QString _toQString(CFStringRef str)
191+
{
192+
if(!str)
193+
return QString();
194+
CFIndex length = CFStringGetLength(str);
195+
const UniChar *chars = CFStringGetCharactersPtr(str);
196+
if (chars)
197+
return QString(reinterpret_cast<const QChar *>(chars), length);
198+
199+
QVarLengthArray<UniChar> buffer(length);
200+
CFStringGetCharacters(str, CFRangeMake(0, length), buffer.data());
201+
return QString(reinterpret_cast<const QChar *>(buffer.constData()), length);
202+
}
203+
189204
#ifndef QT_BOOTSTRAPPED
190205
QString QStandardPaths::displayName(StandardLocation type)
191206
{
@@ -197,12 +212,12 @@ QString QStandardPaths::displayName(StandardLocation type)
197212
if (err)
198213
return QString();
199214

200-
QCFString displayName;
215+
CFString displayName;
201216
err = LSCopyDisplayNameForRef(&ref, &displayName);
202217
if (err)
203218
return QString();
204219

205-
return static_cast<QString>(displayName);
220+
return _toQString(displayName);
206221
}
207222
#endif
208223

0 commit comments

Comments
 (0)