Skip to content

Commit

Permalink
XCB: Silence clipboard warning "SelectionRequest too old"
Browse files Browse the repository at this point in the history
Use the predefined logging category for clipboard warnings
and change the offending  warning to qCDebug() so that it is silent
by default.

Pick-to: 6.2 5.15
Fixes: QTBUG-60257
Change-Id: Icf1bc84cd64207b94ef471f13090c43b45e20728
Reviewed-by: Liang Qi <[email protected]>
  • Loading branch information
FriedemannKleint committed Oct 13, 2021
1 parent 9422dd0 commit 2160042
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/plugins/platforms/xcb/qxcbclipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class QXcbClipboardMime : public QXcbMime
break;

default:
qWarning("QXcbClipboardMime: Internal error: Unsupported clipboard mode");
qCWarning(lcQpaClipboard, "QXcbClipboardMime: Internal error: Unsupported clipboard mode");
break;
}
}
Expand Down Expand Up @@ -265,7 +265,7 @@ QXcbClipboard::~QXcbClipboard()
if (auto event = waitForClipboardEvent(m_owner, XCB_SELECTION_NOTIFY, true)) {
free(event);
} else {
qWarning("QXcbClipboard: Unable to receive an event from the "
qCWarning(lcQpaClipboard, "QXcbClipboard: Unable to receive an event from the "
"clipboard manager in a reasonable time");
}
}
Expand Down Expand Up @@ -371,7 +371,7 @@ void QXcbClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
xcb_set_selection_owner(xcb_connection(), newOwner, modeAtom, connection()->time());

if (getSelectionOwner(modeAtom) != newOwner) {
qWarning("QXcbClipboard::setMimeData: Cannot set X11 selection owner");
qCWarning(lcQpaClipboard, "QXcbClipboard::setMimeData: Cannot set X11 selection owner");
}

emitChanged(mode);
Expand Down Expand Up @@ -538,7 +538,7 @@ void QXcbClipboard::handleSelectionClearRequest(xcb_selection_clear_event_t *eve
void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req)
{
if (requestor() && req->requestor == requestor()) {
qWarning("QXcbClipboard: Selection request should be caught before");
qCWarning(lcQpaClipboard, "QXcbClipboard: Selection request should be caught before");
return;
}

Expand All @@ -553,22 +553,23 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req)
QMimeData *d;
QClipboard::Mode mode = modeForAtom(req->selection);
if (mode > QClipboard::Selection) {
qWarning() << "QXcbClipboard: Unknown selection" << connection()->atomName(req->selection);
qCWarning(lcQpaClipboard, "QXcbClipboard: Unknown selection %s",
connection()->atomName(req->selection).constData());
xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
return;
}

d = m_clientClipboard[mode];

if (!d) {
qWarning("QXcbClipboard: Cannot transfer data, no data available");
qCWarning(lcQpaClipboard, "QXcbClipboard: Cannot transfer data, no data available");
xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
return;
}

if (m_timestamp[mode] == XCB_CURRENT_TIME // we don't own the selection anymore
|| (req->time != XCB_CURRENT_TIME && req->time < m_timestamp[mode])) {
qWarning("QXcbClipboard: SelectionRequest too old");
qCDebug(lcQpaClipboard, "QXcbClipboard: SelectionRequest too old");
xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
return;
}
Expand Down Expand Up @@ -623,7 +624,7 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req)
property, XCB_ATOM_INTEGER, 32, 1, &m_timestamp[mode]);
ret = property;
} else {
qWarning("QXcbClipboard: Invalid data timestamp");
qCWarning(lcQpaClipboard, "QXcbClipboard: Invalid data timestamp");
}
} else if (target == targetsAtom) {
ret = sendTargetsSelection(d, req->requestor, property);
Expand Down Expand Up @@ -728,7 +729,7 @@ bool QXcbClipboard::clipboardReadProperty(xcb_window_t win, xcb_atom_t property,
// recover -- this shouldn't normally happen, but it doesn't
// hurt to be defensive
if ((int)(buffer_offset + length) > buffer->size()) {
qWarning("QXcbClipboard: buffer overflow");
qCWarning(lcQpaClipboard, "QXcbClipboard: buffer overflow");
length = buffer->size() - buffer_offset;

// escape loop
Expand Down

0 comments on commit 2160042

Please sign in to comment.