From db3fe712d3dc677073f6b41fd32c5ca49de69982 Mon Sep 17 00:00:00 2001 From: Hualet Wang Date: Fri, 23 Jun 2017 16:57:02 +0800 Subject: [PATCH] Revert "appitem: make fetch icon asynchronous" This reverts commit a5b044e58532f7bb3106730cae53329258cec2dc. because QIcon used with multithread are not safe Change-Id: I1502a23358b7b2f90d164f36861870f6c9df280c --- frame/frame.pro | 2 +- frame/item/appitem.cpp | 42 +++++++------------------------------ frame/item/appitem.h | 4 ---- frame/util/themeappicon.cpp | 2 +- frame/util/themeappicon.h | 2 +- 5 files changed, 11 insertions(+), 41 deletions(-) diff --git a/frame/frame.pro b/frame/frame.pro index ce14de2f8..192ecbb72 100644 --- a/frame/frame.pro +++ b/frame/frame.pro @@ -1,7 +1,7 @@ include(../interfaces/interfaces.pri) -QT += core gui widgets dbus x11extras svg concurrent +QT += core gui widgets dbus x11extras svg TARGET = dde-dock DESTDIR = $$_PRO_FILE_PWD_/../ diff --git a/frame/item/appitem.cpp b/frame/item/appitem.cpp index c492c6bd5..e43e61d0e 100644 --- a/frame/item/appitem.cpp +++ b/frame/item/appitem.cpp @@ -15,9 +15,6 @@ #include #include #include -#include -#include -#include #define APP_DRAG_THRESHOLD 20 @@ -96,13 +93,8 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent) connect(m_appPreviewTips, &_PreviewContainer::requestHidePreview, this, &AppItem::hidePopup, Qt::QueuedConnection); connect(m_appPreviewTips, &_PreviewContainer::requestCheckWindows, m_itemEntry, &DBusDockEntry::Check); - connect(m_smallWatcher, &QFutureWatcher::finished, this, &AppItem::gotSmallIcon); - connect(m_largeWatcher, &QFutureWatcher::finished, this, &AppItem::gotLargeIcon); - - QTimer::singleShot(1, this, [=] { - updateTitle(); - refershIcon(); - }); + updateTitle(); + refershIcon(); } AppItem::~AppItem() @@ -492,22 +484,17 @@ void AppItem::refershIcon() const QString icon = m_itemEntry->icon(); const int iconSize = qMin(width(), height()); - m_smallWatcher->cancel(); - m_largeWatcher->cancel(); - if (DockDisplayMode == Efficient) { -// m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.7); -// m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.9); - m_smallWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.7)); - m_largeWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.9)); + m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.7); + m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.9); } else { -// m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.6); -// m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.8); - m_smallWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.6)); - m_largeWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.8)); + m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.6); + m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.8); } + update(); + m_updateIconGeometryTimer->start(); } @@ -541,16 +528,3 @@ void AppItem::showPreview() showPopupWindow(m_appPreviewTips, true); } -void AppItem::gotSmallIcon() -{ - m_smallIcon = m_smallWatcher->result(); - - update(); -} - -void AppItem::gotLargeIcon() -{ - m_largeIcon = m_largeWatcher->result(); - - update(); -} diff --git a/frame/item/appitem.h b/frame/item/appitem.h index 59aaf9353..66880f6f7 100644 --- a/frame/item/appitem.h +++ b/frame/item/appitem.h @@ -8,7 +8,6 @@ #include #include -#include class AppItem : public DockItem { @@ -57,9 +56,6 @@ private slots: void activeChanged(); void showPreview(); - void gotSmallIcon(); - void gotLargeIcon(); - private: QLabel *m_appNameTips; _PreviewContainer *m_appPreviewTips; diff --git a/frame/util/themeappicon.cpp b/frame/util/themeappicon.cpp index 66cad9758..bf4b2ab8c 100644 --- a/frame/util/themeappicon.cpp +++ b/frame/util/themeappicon.cpp @@ -14,7 +14,7 @@ ThemeAppIcon::~ThemeAppIcon() } -QPixmap ThemeAppIcon::getIcon(const QString iconName, const int size) +const QPixmap ThemeAppIcon::getIcon(const QString iconName, const int size) { const int s = size & ~1; diff --git a/frame/util/themeappicon.h b/frame/util/themeappicon.h index 8c6e4e10d..e13222ec0 100644 --- a/frame/util/themeappicon.h +++ b/frame/util/themeappicon.h @@ -10,7 +10,7 @@ public: explicit ThemeAppIcon(QObject *parent = 0); ~ThemeAppIcon(); - static QPixmap getIcon(const QString iconName, const int size); + static const QPixmap getIcon(const QString iconName, const int size); }; #endif // THEMEAPPICON_H