diff options
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoahelpers.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoahelpers.mm | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 5f97e2996c..f51c21ee9b 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -33,7 +33,6 @@ #include "qcocoahelpers.h" -#include "qcocoaautoreleasepool.h" #include <QtCore> #include <QtGui> @@ -270,10 +269,14 @@ bool operator<(const KeyPair &entry, const Qt::Key &key) return entry.qtKey < key; } -static bool qtKey2CocoaKeySortLessThan(const KeyPair &entry1, const KeyPair &entry2) +struct qtKey2CocoaKeySortLessThan { - return entry1.qtKey < entry2.qtKey; -} + typedef bool result_type; + Q_DECL_CONSTEXPR result_type operator()(const KeyPair &entry1, const KeyPair &entry2) const Q_DECL_NOTHROW + { + return entry1.qtKey < entry2.qtKey; + } +}; static const int NumEntries = 59; static const KeyPair entries[NumEntries] = { @@ -353,7 +356,7 @@ QChar qt_mac_qtKey2CocoaKey(Qt::Key key) mustInit = false; for (int i=0; i<NumEntries; ++i) rev_entries[i] = entries[i]; - std::sort(rev_entries.begin(), rev_entries.end(), qtKey2CocoaKeySortLessThan); + std::sort(rev_entries.begin(), rev_entries.end(), qtKey2CocoaKeySortLessThan()); } const QVector<KeyPair>::iterator i = std::lower_bound(rev_entries.begin(), rev_entries.end(), key); @@ -619,7 +622,7 @@ QString qt_mac_applicationName() if (appName.isEmpty()) { QString arg0 = QGuiApplicationPrivate::instance()->appName(); if (arg0.contains("/")) { - QStringList parts = arg0.split("/"); + QStringList parts = arg0.split(QLatin1Char('/')); appName = parts.at(parts.count() - 1); } else { appName = arg0; @@ -630,11 +633,15 @@ QString qt_mac_applicationName() int qt_mac_mainScreenHeight() { - QCocoaAutoReleasePool pool; - // The first screen in the screens array is documented - // to have the (0,0) origin. - NSRect screenFrame = [[[NSScreen screens] firstObject] frame]; - return screenFrame.size.height; + QMacAutoReleasePool pool; + NSArray *screens = [NSScreen screens]; + if ([screens count] > 0) { + // The first screen in the screens array is documented + // to have the (0,0) origin. + NSRect screenFrame = [[screens objectAtIndex: 0] frame]; + return screenFrame.size.height; + } + return 0; } int qt_mac_flipYCoordinate(int y) |