xwayland/selection_source: reduce atomic refcount inc/decrement
This commit is contained in:
parent
e5c22cefba
commit
ed16a957d3
1 changed files with 10 additions and 9 deletions
|
@ -18,6 +18,7 @@
|
||||||
#include "wayland_server.h"
|
#include "wayland_server.h"
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <span>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <xwayland_logging.h>
|
#include <xwayland_logging.h>
|
||||||
|
@ -213,35 +214,35 @@ void X11Source::handleTargets()
|
||||||
|
|
||||||
Mimes all;
|
Mimes all;
|
||||||
xcb_atom_t *value = static_cast<xcb_atom_t *>(xcb_get_property_value(reply));
|
xcb_atom_t *value = static_cast<xcb_atom_t *>(xcb_get_property_value(reply));
|
||||||
for (uint32_t i = 0; i < reply->value_len; i++) {
|
for (xcb_atom_t value : std::span(value, reply->value_len)) {
|
||||||
if (value[i] == XCB_ATOM_NONE) {
|
if (value == XCB_ATOM_NONE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto mimeStrings = Selection::atomToMimeTypes(value[i]);
|
const auto mimeStrings = Selection::atomToMimeTypes(value);
|
||||||
if (mimeStrings.isEmpty()) {
|
if (mimeStrings.isEmpty()) {
|
||||||
// TODO: this should never happen? assert?
|
// TODO: this should never happen? assert?
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto mimeIt = std::find_if(m_offers.begin(), m_offers.end(),
|
const auto mimeIt = std::find_if(m_offers.begin(), m_offers.end(),
|
||||||
[value, i](const Mime &mime) {
|
[value](const Mime &mime) {
|
||||||
return mime.second == value[i];
|
return mime.second == value;
|
||||||
});
|
});
|
||||||
|
|
||||||
auto mimePair = Mime(mimeStrings[0], value[i]);
|
auto mimePair = Mime(mimeStrings[0], value);
|
||||||
if (mimeIt == m_offers.end()) {
|
if (mimeIt == m_offers.end()) {
|
||||||
added << mimePair.first;
|
added << mimePair.first;
|
||||||
} else {
|
} else {
|
||||||
m_offers.removeAll(mimePair);
|
m_offers.removeAll(mimePair);
|
||||||
}
|
}
|
||||||
all << mimePair;
|
all << std::move(mimePair);
|
||||||
}
|
}
|
||||||
// all left in m_offers are not in the updated targets
|
// all left in m_offers are not in the updated targets
|
||||||
for (const auto &mimePair : std::as_const(m_offers)) {
|
for (const auto &mimePair : std::as_const(m_offers)) {
|
||||||
removed << mimePair.first;
|
removed << mimePair.first;
|
||||||
}
|
}
|
||||||
m_offers = all;
|
m_offers = std::move(all);
|
||||||
|
|
||||||
if (!added.isEmpty() || !removed.isEmpty()) {
|
if (!added.isEmpty() || !removed.isEmpty()) {
|
||||||
Q_EMIT offersChanged(added, removed);
|
Q_EMIT offersChanged(added, removed);
|
||||||
|
|
Loading…
Reference in a new issue