From bfe5042132ba3fa611e134a1c38515a432dcef26 Mon Sep 17 00:00:00 2001 From: Arnaud Bienner Date: Mon, 21 Sep 2015 00:21:39 +0200 Subject: [PATCH] Don't give focus to search box when setting the reseting the text to empty string on OS X, otherwise it will get focus when it doesn't need to --- 3rdparty/qocoa/qsearchfield_mac.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/3rdparty/qocoa/qsearchfield_mac.mm b/3rdparty/qocoa/qsearchfield_mac.mm index f1f5d8ccf..e4b78d9d8 100644 --- a/3rdparty/qocoa/qsearchfield_mac.mm +++ b/3rdparty/qocoa/qsearchfield_mac.mm @@ -166,8 +166,10 @@ void QSearchField::setText(const QString &text) NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [pimpl->nsSearchField setStringValue:fromQString(text)]; - [pimpl->nsSearchField selectText:pimpl->nsSearchField]; - [[pimpl->nsSearchField currentEditor] setSelectedRange:NSMakeRange([[pimpl->nsSearchField stringValue] length], 0)]; + if (!text.isEmpty()) { + [pimpl->nsSearchField selectText:pimpl->nsSearchField]; + [[pimpl->nsSearchField currentEditor] setSelectedRange:NSMakeRange([[pimpl->nsSearchField stringValue] length], 0)]; + } [pool drain]; }