From cb8eb0f86c1bbdfbd6cfa789e7596a0e05d7fe66 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sun, 15 Mar 2020 14:35:41 +0100 Subject: Get rid of QRegExp usage in the cocoa plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I9789e1637a17809082458e946fa7c49ab9269537 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qnswindowdelegate.mm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/cocoa/qnswindowdelegate.mm') diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm index 9502a315d8..3ad9085dea 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -47,7 +47,13 @@ #include #include -static QRegExp whitespaceRegex = QRegExp(QStringLiteral("\\s*")); +static inline bool isWhiteSpace(const QString &s) +{ + for (int i = 0; i < s.size(); ++i) + if (!s.at(i).isSpace()) + return false; + return true; +} static QCocoaWindow *toPlatformWindow(NSWindow *window) { @@ -113,7 +119,7 @@ static QCocoaWindow *toPlatformWindow(NSWindow *window) // Only pop up document path if the filename is non-empty. We allow whitespace, to // allow faking a window icon by setting the file path to a single space character. - return !whitespaceRegex.exactMatch(platformWindow->window()->filePath()); + return !isWhiteSpace(platformWindow->window()->filePath()); } - (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard @@ -127,6 +133,6 @@ static QCocoaWindow *toPlatformWindow(NSWindow *window) // Only allow drag if the filename is non-empty. We allow whitespace, to // allow faking a window icon by setting the file path to a single space. - return !whitespaceRegex.exactMatch(platformWindow->window()->filePath()); + return !isWhiteSpace(platformWindow->window()->filePath()); } @end -- cgit v1.2.3