From cc599efbef7d66c5733eb49f181319497c63bb30 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 9 Apr 2024 11:35:23 +0200 Subject: [PATCH] Fix potential problems with code related to styling the tray menu --- tray/gui/traymenu.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tray/gui/traymenu.cpp b/tray/gui/traymenu.cpp index 39451aa..3dc3027 100644 --- a/tray/gui/traymenu.cpp +++ b/tray/gui/traymenu.cpp @@ -149,7 +149,9 @@ void TrayMenu::setWindowType(WindowType windowType) if (m_isWindows11Style) { updateContentMargins(); if (windowType == WindowType::Popup) { - style()->polish(this); + if (auto *const s = style()) { + s->polish(this); + } } } #endif @@ -230,9 +232,9 @@ void TrayMenu::paintEvent(QPaintEvent *event) QMenu::paintEvent(event); } else { #ifdef TRAY_MENU_HANDLE_WINDOWS11_STYLE - const auto p = m_windowType != TrayMenu::WindowType::Popup && m_isWindows11Style ? QGuiApplication::palette() : palette(); + const auto p = m_windowType != TrayMenu::WindowType::Popup && m_isWindows11Style ? QGuiApplication::palette() : QPalette(palette()); #else - const auto p = palette(); + const auto &p = palette(); #endif QPainter(this).fillRect(event->rect(), p.color(backgroundRole())); QWidget::paintEvent(event);