D22488: invoke QIcon::setFallbackThemeName a bit later

Albert Astals Cid noreply at phabricator.kde.org
Sat May 23 00:49:13 BST 2020


aacid added a comment.


  Now i understand this is causing relatively several issues, sorry for dropping the ball, so we should probably fix for users before Qt 5.15.1
  
  What about something like
  
    diff --git a/src/kicontheme.cpp b/src/kicontheme.cpp
    index 4f5d9d5..62fc9d7 100644
    --- a/src/kicontheme.cpp
    +++ b/src/kicontheme.cpp
    @@ -70,6 +70,19 @@ void initRCCIconTheme()
     }
     Q_COREAPP_STARTUP_FUNCTION(initRCCIconTheme)
     
    +class SetBreezeFallbackHelper : public QObject
    +{
    +    bool event(QEvent *e) override
    +    {
    +        if (e->type() == QEvent::User) {
    +            QIcon::setFallbackThemeName(QStringLiteral("breeze"));
    +            deleteLater();
    +            return true;
    +        }
    +        return QObject::event(e);
    +    }
    +};
    +
     // Set the icon theme fallback to breeze
     // Most of our apps use "lots" of icons that most of the times
     // are only available with breeze, we still honour the user icon
    @@ -77,7 +90,8 @@ Q_COREAPP_STARTUP_FUNCTION(initRCCIconTheme)
     // since it's almost sure it'll be there
     static void setBreezeFallback()
     {
    -    QIcon::setFallbackThemeName(QStringLiteral("breeze"));
    +    SetBreezeFallbackHelper *helper = new SetBreezeFallbackHelper();
    +    QCoreApplication::instance()->postEvent(helper, new QEvent(QEvent::User), Qt::HighEventPriority);
     }
     
     Q_COREAPP_STARTUP_FUNCTION(setBreezeFallback)
  
  It's still totally bad since it only sets the fallback after QGuiApplication *starts* running (which is mega late since most of the constructors will have already be created), but at least doesn't rely on the app creating a KIconTheme.

REPOSITORY
  R302 KIconThemes

REVISION DETAIL
  https://phabricator.kde.org/D22488

To: mart, #frameworks, #plasma
Cc: aacid, mlaurent, broulik, kde-frameworks-devel, LeGast00n, cblack, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20200522/a6cf8e04/attachment.htm>


More information about the Kde-frameworks-devel mailing list