From f43c9697bcae997be3eb6db9504f3d7b64601148 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 27 Sep 2016 14:55:09 +0200 Subject: Plug QMimeData leaks in QXcbClipboard QXcbClipboard failed to delete the various QMimeData instances it owns. For m_xClipboard, where the two QXcbClipboardMime instances are never the same, fix the leak by using a scoped instead of a naked pointer. For m_clientClipboard, where the two QMimeData could be identical objects, keep the naked pointers, but delete the objects manually in the QXcbClipboard destructor, paying attention to the case where they're the same object. Change-Id: I5ce0e3e8fcec068aeb344ca806cdf2667378e946 Reviewed-by: Thiago Macieira --- src/plugins/platforms/xcb/qxcbclipboard.cpp | 12 +++++++----- src/plugins/platforms/xcb/qxcbclipboard.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index 8b75c130fb..d44ebae8f7 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -269,8 +269,6 @@ QXcbClipboard::QXcbClipboard(QXcbConnection *c) { Q_ASSERT(QClipboard::Clipboard == 0); Q_ASSERT(QClipboard::Selection == 1); - m_xClipboard[QClipboard::Clipboard] = 0; - m_xClipboard[QClipboard::Selection] = 0; m_clientClipboard[QClipboard::Clipboard] = 0; m_clientClipboard[QClipboard::Selection] = 0; m_timestamp[QClipboard::Clipboard] = XCB_CURRENT_TIME; @@ -323,6 +321,10 @@ QXcbClipboard::~QXcbClipboard() } free(reply); } + + if (m_clientClipboard[QClipboard::Clipboard] != m_clientClipboard[QClipboard::Selection]) + delete m_clientClipboard[QClipboard::Clipboard]; + delete m_clientClipboard[QClipboard::Selection]; } void QXcbClipboard::incrTransactionPeeker(xcb_generic_event_t *ge, bool &accepted) @@ -372,9 +374,9 @@ QMimeData * QXcbClipboard::mimeData(QClipboard::Mode mode) return m_clientClipboard[mode]; } else { if (!m_xClipboard[mode]) - m_xClipboard[mode] = new QXcbClipboardMime(mode, this); + m_xClipboard[mode].reset(new QXcbClipboardMime(mode, this)); - return m_xClipboard[mode]; + return m_xClipboard[mode].data(); } } @@ -724,7 +726,7 @@ void QXcbClipboard::handleXFixesSelectionRequest(xcb_xfixes_selection_notify_eve // here we care only about the xfixes events that come from non Qt processes if (event->owner != XCB_NONE && event->owner != owner()) { if (!m_xClipboard[mode]) { - m_xClipboard[mode] = new QXcbClipboardMime(mode, this); + m_xClipboard[mode].reset(new QXcbClipboardMime(mode, this)); } else { m_xClipboard[mode]->reset(); } diff --git a/src/plugins/platforms/xcb/qxcbclipboard.h b/src/plugins/platforms/xcb/qxcbclipboard.h index 10f07047d8..f9a34f4f3d 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.h +++ b/src/plugins/platforms/xcb/qxcbclipboard.h @@ -92,7 +92,7 @@ private: QClipboard::Mode modeForAtom(xcb_atom_t atom) const; // Selection and Clipboard - QXcbClipboardMime *m_xClipboard[2]; + QScopedPointer m_xClipboard[2]; QMimeData *m_clientClipboard[2]; xcb_timestamp_t m_timestamp[2]; -- cgit v1.2.3 From 9ab60b9c0db453fb598e42d91ce3217944afd9b6 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 8 Jun 2016 17:58:21 -0700 Subject: QCocoaEventDispatcher: Save interrupt state between embedded calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since QCocoaEventDispatcher::processEvents() resets the interrupt state, this may prevent a higher level event loop from returning. For example, calling QMenu::exec() and, as a result of an action being triggered, the application calls QCoreApplication::processEvents() after QMenu::hideEvent(). In this case, the menu event loop can be stuck until we run another event loop. Task-number: QTBUG-53947 Change-Id: If7efe1c3c07f7222c695195cbb4f41715e49b02e Reviewed-by: Timur Pocheptsov Reviewed-by: Wayne Arnold Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 1865624d57..1cfb3ecff9 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -342,7 +342,7 @@ static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRun bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) { Q_D(QCocoaEventDispatcher); - d->interrupt = false; + QBoolBlocker interruptBlocker(d->interrupt, false); bool interruptLater = false; QtCocoaInterruptDispatcher::cancelInterruptLater(); -- cgit v1.2.3