diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/text/qtextengine.cpp | 9 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosinputcontext.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosmenu.mm | 1 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiostextresponder.mm | 11 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbcursor.cpp | 24 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 22 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.h | 3 | ||||
-rw-r--r-- | src/testlib/qtestcase.h | 54 | ||||
-rw-r--r-- | src/widgets/kernel/qlayoutitem.cpp | 14 |
9 files changed, 95 insertions, 44 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 2f069a9abd..4205774ee9 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2069,6 +2069,9 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix font = font.resolve(fnt); } engine = font.d->engineForScript(script); + if (engine) + engine->ref.ref(); + QTextCharFormat::VerticalAlignment valign = f.verticalAlignment(); if (valign == QTextCharFormat::AlignSuperScript || valign == QTextCharFormat::AlignSubScript) { if (font.pointSize() != -1) @@ -2076,16 +2079,14 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix else font.setPixelSize((font.pixelSize() * 2) / 3); scaledEngine = font.d->engineForScript(script); + if (scaledEngine) + scaledEngine->ref.ref(); } - if (engine) - engine->ref.ref(); if (feCache.prevFontEngine) releaseCachedFontEngine(feCache.prevFontEngine); feCache.prevFontEngine = engine; - if (scaledEngine) - scaledEngine->ref.ref(); if (feCache.prevScaledFontEngine) releaseCachedFontEngine(feCache.prevScaledFontEngine); feCache.prevScaledFontEngine = scaledEngine; diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h index 2b0643f26e..ffb21d6afe 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.h +++ b/src/plugins/platforms/ios/qiosinputcontext.h @@ -49,6 +49,7 @@ const char kImePlatformDataInputView[] = "inputView"; const char kImePlatformDataInputAccessoryView[] = "inputAccessoryView"; +const char kImePlatformDataHideShortcutsBar[] = "hideShortcutsBar"; const char kImePlatformDataReturnKeyType[] = "returnKeyType"; QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm index 41594232ff..24d8559cc8 100644 --- a/src/plugins/platforms/ios/qiosmenu.mm +++ b/src/plugins/platforms/ios/qiosmenu.mm @@ -519,6 +519,7 @@ bool QIOSMenu::eventFilter(QObject *obj, QEvent *event) QVariantMap imPlatformData = queryEvent->value(Qt::ImPlatformData).toMap(); imPlatformData.insert(kImePlatformDataInputView, QVariant::fromValue(static_cast<void *>(m_pickerView))); imPlatformData.insert(kImePlatformDataInputAccessoryView, QVariant::fromValue(static_cast<void *>(m_pickerView.toolbar))); + imPlatformData.insert(kImePlatformDataHideShortcutsBar, true); queryEvent->setValue(Qt::ImPlatformData, imPlatformData); queryEvent->setValue(Qt::ImEnabled, true); diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index 9a077323e7..e31584d581 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -236,6 +236,17 @@ self.inputView = [[[WrapperView alloc] initWithView:inputView] autorelease]; if (UIView *accessoryView = static_cast<UIView *>(platformData.value(kImePlatformDataInputAccessoryView).value<void *>())) self.inputAccessoryView = [[[WrapperView alloc] initWithView:accessoryView] autorelease]; + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_9_0) { + if (platformData.value(kImePlatformDataHideShortcutsBar).toBool()) { + // According to the docs, leadingBarButtonGroups/trailingBarButtonGroups should be set to nil to hide the shortcuts bar. + // However, starting with iOS 10, the API has been surrounded with NS_ASSUME_NONNULL, which contradicts this and causes + // compiler warnings. And assigning just an empty array causes layout asserts. Hence, we assign empty button groups instead. + UIBarButtonItemGroup *leading = [[[UIBarButtonItemGroup alloc] initWithBarButtonItems:@[] representativeItem:nil] autorelease]; + UIBarButtonItemGroup *trailing = [[[UIBarButtonItemGroup alloc] initWithBarButtonItems:@[] representativeItem:nil] autorelease]; + self.inputAssistantItem.leadingBarButtonGroups = @[leading]; + self.inputAssistantItem.trailingBarButtonGroups = @[trailing]; + } + } self.undoManager.groupsByEvent = NO; [self rebuildUndoStack]; diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp index 11e0c998b1..4de4be43d1 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.cpp +++ b/src/plugins/platforms/xcb/qxcbcursor.cpp @@ -359,17 +359,27 @@ void QXcbCursor::changeCursor(QCursor *cursor, QWindow *widget) return; xcb_cursor_t c = XCB_CURSOR_NONE; + bool isBitmapCursor = false; + if (cursor) { - const QXcbCursorCacheKey key(*cursor); - CursorHash::iterator it = m_cursorHash.find(key); - if (it == m_cursorHash.end()) { - const Qt::CursorShape shape = cursor->shape(); - it = m_cursorHash.insert(key, shape == Qt::BitmapCursor ? createBitmapCursor(cursor) : createFontCursor(shape)); + const Qt::CursorShape shape = cursor->shape(); + isBitmapCursor = shape == Qt::BitmapCursor; + + if (!isBitmapCursor) { + const QXcbCursorCacheKey key(*cursor); + CursorHash::iterator it = m_cursorHash.find(key); + if (it == m_cursorHash.end()) { + it = m_cursorHash.insert(key, createFontCursor(shape)); + } + c = it.value(); + } else { + // Do not cache bitmap cursors, as otherwise they have unclear + // lifetime (we effectively leak xcb_cursor_t). + c = createBitmapCursor(cursor); } - c = it.value(); } - w->setCursor(c); + w->setCursor(c, isBitmapCursor); } static int cursorIdForShape(int cshape) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 8b13a90d74..15616c1cea 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -322,6 +322,7 @@ QXcbWindow::QXcbWindow(QWindow *window) , m_lastWindowStateEvent(-1) , m_syncState(NoSyncNeeded) , m_pendingSyncRequest(0) + , m_currentBitmapCursor(XCB_CURSOR_NONE) { setConnection(xcbScreen()->connection()); } @@ -596,6 +597,9 @@ void QXcbWindow::create() QXcbWindow::~QXcbWindow() { + if (m_currentBitmapCursor != XCB_CURSOR_NONE) { + xcb_free_cursor(xcb_connection(), m_currentBitmapCursor); + } if (window()->type() != Qt::ForeignWindow) destroy(); else { @@ -2665,10 +2669,22 @@ bool QXcbWindow::setMouseGrabEnabled(bool grab) return result; } -void QXcbWindow::setCursor(xcb_cursor_t cursor) +void QXcbWindow::setCursor(xcb_cursor_t cursor, bool isBitmapCursor) { - xcb_change_window_attributes(xcb_connection(), m_window, XCB_CW_CURSOR, &cursor); - xcb_flush(xcb_connection()); + xcb_connection_t *conn = xcb_connection(); + + xcb_change_window_attributes(conn, m_window, XCB_CW_CURSOR, &cursor); + xcb_flush(conn); + + if (m_currentBitmapCursor != XCB_CURSOR_NONE) { + xcb_free_cursor(conn, m_currentBitmapCursor); + } + + if (isBitmapCursor) { + m_currentBitmapCursor = cursor; + } else { + m_currentBitmapCursor = XCB_CURSOR_NONE; + } } void QXcbWindow::windowEvent(QEvent *event) diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index f62938ba8a..717c424e11 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -103,7 +103,7 @@ public: bool setKeyboardGrabEnabled(bool grab) Q_DECL_OVERRIDE; bool setMouseGrabEnabled(bool grab) Q_DECL_OVERRIDE; - void setCursor(xcb_cursor_t cursor); + void setCursor(xcb_cursor_t cursor, bool isBitmapCursor); QSurfaceFormat format() const Q_DECL_OVERRIDE; @@ -271,6 +271,7 @@ protected: SyncState m_syncState; QXcbSyncWindowRequest *m_pendingSyncRequest; + xcb_cursor_t m_currentBitmapCursor; }; QT_END_NAMESPACE diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 83ecaab8df..fe74268481 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -130,57 +130,57 @@ do {\ #endif // !QT_NO_EXCEPTIONS -#define QTRY_LOOP_IMPL(__expr, __timeoutValue, __step) \ - if (!(__expr)) { \ +#define QTRY_LOOP_IMPL(expr, timeoutValue, step) \ + if (!(expr)) { \ QTest::qWait(0); \ } \ - int __i = 0; \ - for (; __i < __timeoutValue && !(__expr); __i += __step) { \ - QTest::qWait(__step); \ + int qt_test_i = 0; \ + for (; qt_test_i < timeoutValue && !(expr); qt_test_i += step) { \ + QTest::qWait(step); \ } -#define QTRY_TIMEOUT_DEBUG_IMPL(__expr, __timeoutValue, __step)\ - if (!(__expr)) { \ - QTRY_LOOP_IMPL((__expr), (2 * __timeoutValue), __step);\ - if (__expr) { \ +#define QTRY_TIMEOUT_DEBUG_IMPL(expr, timeoutValue, step)\ + if (!(expr)) { \ + QTRY_LOOP_IMPL((expr), (2 * timeoutValue), step);\ + if (expr) { \ QString msg = QString::fromUtf8("QTestLib: This test case check (\"%1\") failed because the requested timeout (%2 ms) was too short, %3 ms would have been sufficient this time."); \ - msg = msg.arg(QString::fromUtf8(#__expr)).arg(__timeoutValue).arg(__timeoutValue + __i); \ + msg = msg.arg(QString::fromUtf8(#expr)).arg(timeoutValue).arg(timeoutValue + qt_test_i); \ QFAIL(qPrintable(msg)); \ } \ } -#define QTRY_IMPL(__expr, __timeout)\ - const int __step = 50; \ - const int __timeoutValue = __timeout; \ - QTRY_LOOP_IMPL((__expr), __timeoutValue, __step); \ - QTRY_TIMEOUT_DEBUG_IMPL((__expr), __timeoutValue, __step)\ +#define QTRY_IMPL(expr, timeout)\ + const int qt_test_step = 50; \ + const int qt_test_timeoutValue = timeout; \ + QTRY_LOOP_IMPL((expr), qt_test_timeoutValue, qt_test_step); \ + QTRY_TIMEOUT_DEBUG_IMPL((expr), qt_test_timeoutValue, qt_test_step)\ // Will try to wait for the expression to become true while allowing event processing -#define QTRY_VERIFY_WITH_TIMEOUT(__expr, __timeout) \ +#define QTRY_VERIFY_WITH_TIMEOUT(expr, timeout) \ do { \ - QTRY_IMPL((__expr), __timeout);\ - QVERIFY(__expr); \ + QTRY_IMPL((expr), timeout);\ + QVERIFY(expr); \ } while (0) -#define QTRY_VERIFY(__expr) QTRY_VERIFY_WITH_TIMEOUT((__expr), 5000) +#define QTRY_VERIFY(expr) QTRY_VERIFY_WITH_TIMEOUT((expr), 5000) // Will try to wait for the expression to become true while allowing event processing -#define QTRY_VERIFY2_WITH_TIMEOUT(__expr, __messageExpression, __timeout) \ +#define QTRY_VERIFY2_WITH_TIMEOUT(expr, messageExpression, timeout) \ do { \ - QTRY_IMPL((__expr), __timeout);\ - QVERIFY2(__expr, __messageExpression); \ + QTRY_IMPL((expr), timeout);\ + QVERIFY2(expr, messageExpression); \ } while (0) -#define QTRY_VERIFY2(__expr, __messageExpression) QTRY_VERIFY2_WITH_TIMEOUT((__expr), (__messageExpression), 5000) +#define QTRY_VERIFY2(expr, messageExpression) QTRY_VERIFY2_WITH_TIMEOUT((expr), (messageExpression), 5000) // Will try to wait for the comparison to become successful while allowing event processing -#define QTRY_COMPARE_WITH_TIMEOUT(__expr, __expected, __timeout) \ +#define QTRY_COMPARE_WITH_TIMEOUT(expr, expected, timeout) \ do { \ - QTRY_IMPL(((__expr) == (__expected)), __timeout);\ - QCOMPARE((__expr), __expected); \ + QTRY_IMPL(((expr) == (expected)), timeout);\ + QCOMPARE((expr), expected); \ } while (0) -#define QTRY_COMPARE(__expr, __expected) QTRY_COMPARE_WITH_TIMEOUT((__expr), __expected, 5000) +#define QTRY_COMPARE(expr, expected) QTRY_COMPARE_WITH_TIMEOUT((expr), expected, 5000) #define QSKIP_INTERNAL(statement) \ do {\ diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index 76568a2c33..ee0c28ec76 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -306,6 +306,8 @@ void QLayoutItem::invalidate() /*! If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned. This function provides type-safe casting. + + \sa spacerItem(), widget() */ QLayout * QLayoutItem::layout() { @@ -315,6 +317,8 @@ QLayout * QLayoutItem::layout() /*! If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise 0 is returned. This function provides type-safe casting. + + \sa layout(), widget() */ QSpacerItem * QLayoutItem::spacerItem() { @@ -345,8 +349,14 @@ QSpacerItem * QSpacerItem::spacerItem() */ /*! - If this item is a QWidget, it is returned as a QWidget; otherwise - 0 is returned. This function provides type-safe casting. + If this item manages a QWidget, returns that widget. Otherwise, + \c nullptr is returned. + + \note While the functions layout() and spacerItem() perform casts, this + function returns another object: QLayout and QSpacerItem inherit QLayoutItem, + while QWidget does not. + + \sa layout(), spacerItem() */ QWidget * QLayoutItem::widget() { |