From 60ebdbe352c50f100e46b3962a9bc44509224697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 15 Jan 2015 17:06:38 +0100 Subject: [PATCH] Improve reading the color scheme in Client Only emit paletteChanged signal and repaint decoration if the palette actually changed. Even more important: check for path.isEmpty() instead of path.isNull(). ::isNull() returns false for "" causing a costly creation for default color scheme. REVIEW: 122083 --- client.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/client.cpp b/client.cpp index 90629cc6c8..12fbd5083c 100644 --- a/client.cpp +++ b/client.cpp @@ -2294,13 +2294,17 @@ void Client::updateColorScheme() // TODO: move into KWindowInfo QString path = QString::fromUtf8(Xcb::StringProperty(m_client, atoms->kde_color_sheme)); path = rules()->checkDecoColor(path); - if (!path.isNull()) { - m_palette = KColorScheme::createApplicationPalette(KSharedConfig::openConfig(path)); + QPalette p = m_palette; + if (!path.isEmpty()) { + p = KColorScheme::createApplicationPalette(KSharedConfig::openConfig(path)); } else { - m_palette = QApplication::palette(); + p = QApplication::palette(); + } + if (p != m_palette) { + m_palette = p; + emit paletteChanged(m_palette); + triggerDecorationRepaint(); } - emit paletteChanged(m_palette); - triggerDecorationRepaint(); } bool Client::isClient() const