Compare commits

...

4 commits

Author SHA1 Message Date
c57ac4b1f2
core/menu: disconnect menu before unref when changed 2024-09-15 16:06:20 -07:00
08966f91c5
service/tray: always mark the root menu item as having children
Blueman doesn't for some reason. This causes
PlatformMenuEntry::display to crash after ::relayout created a QAction
instead of a QMenu.

Fixes #5
2024-09-15 15:57:29 -07:00
84e3f04f3c
service/tray: disconnect menu from handle on deletion
Fixes loaded being set to true after deleting the menu.
2024-09-15 15:32:01 -07:00
bdc9fe958b
service/tray: delete image pixmaps created with new[] using delete[] 2024-09-15 13:50:00 -07:00
3 changed files with 8 additions and 5 deletions

View file

@ -71,8 +71,8 @@ void QsMenuOpener::setMenu(QsMenuHandle* menu) {
QObject::disconnect(this->mMenu, nullptr, this, nullptr);
if (this->mMenu->menu()) {
this->mMenu->menu()->unref();
QObject::disconnect(this->mMenu->menu(), nullptr, this, nullptr);
this->mMenu->menu()->unref();
}
this->mMenu->unrefHandle();

View file

@ -98,7 +98,7 @@ void DBusMenuItem::updateLayout() const {
this->menu->updateLayout(this->id, -1);
}
bool DBusMenuItem::hasChildren() const { return this->displayChildren; }
bool DBusMenuItem::hasChildren() const { return this->displayChildren || this->id == 0; }
QQmlListProperty<QsMenuEntry> DBusMenuItem::children() {
return QQmlListProperty<QsMenuEntry>(
@ -545,6 +545,9 @@ void DBusMenuHandle::onMenuPathChanged() {
qCDebug(logDbusMenu) << "Updating" << this << "with refcount" << this->refcount;
if (this->mMenu) {
// Without this, layout updated can be sent after mMenu is set to null,
// leaving loaded = true while mMenu = nullptr.
QObject::disconnect(&this->mMenu->rootItem, nullptr, this, nullptr);
this->mMenu->deleteLater();
this->mMenu = nullptr;
this->loaded = false;

View file

@ -14,7 +14,7 @@ QImage DBusSniIconPixmap::createImage() const {
// fix byte order if on a little endian machine
if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
auto* newbuf = new quint32[this->data.size()];
const auto* oldbuf = reinterpret_cast<const quint32*>(this->data.data()); // NOLINT
const auto* oldbuf = reinterpret_cast<const quint32*>(this->data.constData()); // NOLINT
for (uint i = 0; i < this->data.size() / sizeof(quint32); ++i) {
newbuf[i] = qFromBigEndian(oldbuf[i]); // NOLINT
@ -25,12 +25,12 @@ QImage DBusSniIconPixmap::createImage() const {
this->width,
this->height,
QImage::Format_ARGB32,
[](void* ptr) { delete reinterpret_cast<quint32*>(ptr); }, // NOLINT
[](void* ptr) { delete[] reinterpret_cast<quint32*>(ptr); }, // NOLINT
newbuf
);
} else {
return QImage(
reinterpret_cast<const uchar*>(this->data.data()), // NOLINT
reinterpret_cast<const uchar*>(this->data.constData()), // NOLINT
this->width,
this->height,
QImage::Format_ARGB32