From f0a65179d8da50934ef2ef078c0e6bd221c4eed2 Mon Sep 17 00:00:00 2001 From: David Hallas Date: Wed, 13 Mar 2019 20:27:40 +0100 Subject: Fix crash at shutdown after showing a tooltip Summary: Fix crash at shutdown after showing a tooltip. The commit 94d7e1471e0a81b72285795ad91c4f6196157ae4 introduced a crash that occurs when closing Dolphin after Dolphin has showed a tooltip. This happens because the ToolTipManager::showToolTip function calls the KToopTipWidget::showBelow function passing in the pointer to the DolphinFileMetaDataWidget. But this also passes the ownership of the pointer to the KToopTipWidget as long as a new tooltip is not shown. The problem is that at shutdown, the KToopTipWidget instance will be destoyed first and therefore also destroy the DolphinFileMetaDataWidget instance (which the ToolTipManager still owns through the QScopedPointer) causing it to be deleted twice. The fix for this is simply to swap the order of these two members so that the DolphinFileMetaDataWidget is destroyed first by the QScopedPointer thereby removing it from the KToopTipWidget if it has been set as it's parent. Test Plan: Open Dolphin Show a Tool Tip Close Dolphin Reviewers: #dolphin, elvisangelaccio Reviewed By: #dolphin, elvisangelaccio Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D19737 --- src/views/tooltips/tooltipmanager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/views') diff --git a/src/views/tooltips/tooltipmanager.h b/src/views/tooltips/tooltipmanager.h index 63c723f80..10f88ad76 100644 --- a/src/views/tooltips/tooltipmanager.h +++ b/src/views/tooltips/tooltipmanager.h @@ -84,8 +84,8 @@ private: /// Transient parent of the tooltip, mandatory on Wayland. QWindow* m_transientParent; - QScopedPointer m_fileMetaDataWidget; QScopedPointer m_tooltipWidget; + QScopedPointer m_fileMetaDataWidget; bool m_toolTipRequested; bool m_metaDataRequested; -- cgit v1.3 From 508dc815c75c9db8abaec26ae664ae41bf7f89b5 Mon Sep 17 00:00:00 2001 From: David Hallas Date: Wed, 13 Mar 2019 21:10:11 +0100 Subject: Fix "Add Network Folder" tooltip icon does not show on Breeze, shows correctly on Breeze Dark Summary: Fix "Add Network Folder" tooltip icon does not show on Breeze, shows correctly on Breeze Dark. The fix is taken from D19596. Test Plan: Open Dolphin with the Breeze theme Hover the mouse over the "Add Network Folder" The icon is black on black BUG: 404858 Reviewers: #dolphin, elvisangelaccio, ngraham Reviewed By: #dolphin, elvisangelaccio, ngraham Subscribers: broulik, kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D19738 --- src/views/tooltips/tooltipmanager.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/views') diff --git a/src/views/tooltips/tooltipmanager.cpp b/src/views/tooltips/tooltipmanager.cpp index 9e79a8f70..2990f4249 100644 --- a/src/views/tooltips/tooltipmanager.cpp +++ b/src/views/tooltips/tooltipmanager.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -34,6 +35,15 @@ #include #include +class IconLoaderSingleton { +public: + IconLoaderSingleton() = default; + + KIconLoader self; +}; + +Q_GLOBAL_STATIC(IconLoaderSingleton, iconLoader) + ToolTipManager::ToolTipManager(QWidget* parent) : QObject(parent), m_showToolTipTimer(nullptr), @@ -167,8 +177,13 @@ void ToolTipManager::previewFailed() if (!m_toolTipRequested) { return; } - - const QPixmap pixmap = QIcon::fromTheme(m_item.iconName()).pixmap(128, 128); + QPalette pal; + for (auto state : { QPalette::Active, QPalette::Inactive, QPalette::Disabled }) { + pal.setBrush(state, QPalette::WindowText, pal.toolTipText()); + pal.setBrush(state, QPalette::Window, pal.toolTipBase()); + } + iconLoader->self.setCustomPalette(pal); + const QPixmap pixmap = KDE::icon(m_item.iconName(), &iconLoader->self).pixmap(128, 128); m_fileMetaDataWidget->setPreview(pixmap); if (!m_showToolTipTimer->isActive()) { showToolTip(); -- cgit v1.3