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 <thiago.macieira@intel.com>
This commit is contained in:
parent
d2b4a789c3
commit
f43c9697bc
@ -269,8 +269,6 @@ QXcbClipboard::QXcbClipboard(QXcbConnection *c)
|
|||||||
{
|
{
|
||||||
Q_ASSERT(QClipboard::Clipboard == 0);
|
Q_ASSERT(QClipboard::Clipboard == 0);
|
||||||
Q_ASSERT(QClipboard::Selection == 1);
|
Q_ASSERT(QClipboard::Selection == 1);
|
||||||
m_xClipboard[QClipboard::Clipboard] = 0;
|
|
||||||
m_xClipboard[QClipboard::Selection] = 0;
|
|
||||||
m_clientClipboard[QClipboard::Clipboard] = 0;
|
m_clientClipboard[QClipboard::Clipboard] = 0;
|
||||||
m_clientClipboard[QClipboard::Selection] = 0;
|
m_clientClipboard[QClipboard::Selection] = 0;
|
||||||
m_timestamp[QClipboard::Clipboard] = XCB_CURRENT_TIME;
|
m_timestamp[QClipboard::Clipboard] = XCB_CURRENT_TIME;
|
||||||
@ -323,6 +321,10 @@ QXcbClipboard::~QXcbClipboard()
|
|||||||
}
|
}
|
||||||
free(reply);
|
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)
|
void QXcbClipboard::incrTransactionPeeker(xcb_generic_event_t *ge, bool &accepted)
|
||||||
@ -372,9 +374,9 @@ QMimeData * QXcbClipboard::mimeData(QClipboard::Mode mode)
|
|||||||
return m_clientClipboard[mode];
|
return m_clientClipboard[mode];
|
||||||
} else {
|
} else {
|
||||||
if (!m_xClipboard[mode])
|
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
|
// here we care only about the xfixes events that come from non Qt processes
|
||||||
if (event->owner != XCB_NONE && event->owner != owner()) {
|
if (event->owner != XCB_NONE && event->owner != owner()) {
|
||||||
if (!m_xClipboard[mode]) {
|
if (!m_xClipboard[mode]) {
|
||||||
m_xClipboard[mode] = new QXcbClipboardMime(mode, this);
|
m_xClipboard[mode].reset(new QXcbClipboardMime(mode, this));
|
||||||
} else {
|
} else {
|
||||||
m_xClipboard[mode]->reset();
|
m_xClipboard[mode]->reset();
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ private:
|
|||||||
QClipboard::Mode modeForAtom(xcb_atom_t atom) const;
|
QClipboard::Mode modeForAtom(xcb_atom_t atom) const;
|
||||||
|
|
||||||
// Selection and Clipboard
|
// Selection and Clipboard
|
||||||
QXcbClipboardMime *m_xClipboard[2];
|
QScopedPointer<QXcbClipboardMime> m_xClipboard[2];
|
||||||
QMimeData *m_clientClipboard[2];
|
QMimeData *m_clientClipboard[2];
|
||||||
xcb_timestamp_t m_timestamp[2];
|
xcb_timestamp_t m_timestamp[2];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user