Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I ran into a strange problem with QStyle.
Forum Update on Monday, May 27th 2025

I ran into a strange problem with QStyle.

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5c++17qstyleqstylesheet
4 Posts 2 Posters 424 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    victorman
    wrote on last edited by
    #1

    I am using QT5, but I have occasionally encountered problems during my development.

    When I use this method to refresh the widget,

        widget->setProperty("Hovered", "true");
        widget->style()->unpolish(widget);
        widget->style()->polish(widget);
    

    I occasionally see a crash stack like this

    int std::__1::__cxx_atomic_fetch_sub<int>(std::__1::__cxx_atomic_base_impl<int>*, int, std::__1::memory_order) (atomic:1072)
    std::__1::__atomic_base<int, true>::fetch_sub(int, std::__1::memory_order) (atomic:1725)
    std::__1::__atomic_base<int, true>::operator--() (atomic:1760)
    bool QAtomicOps<int>::deref<int>(std::__1::atomic<int>&) (qatomic_cxx11.h:289)
    QBasicAtomicInteger<int>::deref() (qbasicatomic.h:119)
    QSharedDataPointer<QStyleSheetImageData>::~QSharedDataPointer() (qshareddata.h:93)
    QSharedDataPointer<QStyleSheetImageData>::~QSharedDataPointer() (qshareddata.h:93)
    QRenderRule::~QRenderRule() (qstylesheetstyle.cpp:510)
    QRenderRule::~QRenderRule() (qstylesheetstyle.cpp:510)
    QHashData::free_helper(void (*)(QHashData::Node*)) (qhash.cpp:572)
    QHashData::free_helper(void (*)(QHashData::Node*)) (qhash.cpp:572)
    QHash<int, QHash<unsigned long long, QRenderRule>>::freeData(QHashData*) (qhash.h:619)
    QHash<int, QHash<unsigned long long, QRenderRule>>::~QHash() (qhash.h:250)
    QHash<int, QHash<unsigned long long, QRenderRule>>::~QHash() (qhash.h:250)
    QHashNode<QObject const*, QHash<int, QHash<unsigned long long, QRenderRule>>>::~QHashNode() (qhash.h:147)
    QHashNode<QObject const*, QHash<int, QHash<unsigned long long, QRenderRule>>>::~QHashNode() (qhash.h:147)
    QHash<QObject const*, QHash<int, QHash<unsigned long long, QRenderRule>>>::deleteNode2(QHashData::Node*) (qhash.h:595)
    QHash<QObject const*, QHash<int, QHash<unsigned long long, QRenderRule>>>::deleteNode(QHashNode<QObject const*, QHash<int, QHash<unsigned long long, QRenderRule>>>*) (qhash.h:585)
    QHash<QObject const*, QHash<int, QHash<unsigned long long, QRenderRule>>>::remove(QObject const* const&) (qhash.h:824)
    QStyleSheetStyle::unpolish(QWidget*) (qstylesheetstyle.cpp:2992)
    

    Does anyone know what caused this?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      This sounds similar to https://bugreports.qt.io/browse/QTBUG-69204

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      V 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        This sounds similar to https://bugreports.qt.io/browse/QTBUG-69204

        V Offline
        V Offline
        victorman
        wrote on last edited by
        #3

        @Christian-Ehrlicher Sorry, I forgot to mention my development environment. I am currently using Qt version 5.15.14. The development machine is MacOS m1.

        I see this crash you mentioned (https://bugreports.qt.io/browse/QTBUG-69204) was fixed in 5.12.4, 5.14.0 Alpha.
        When I was using setStyleSheet directly, I occasionally had updateObjects crash.

        setStyleSheet(QString("a{b:c}"));
        

        The crash stack looks like

        int std::__1::__cxx_atomic_load<int>(std::__1::__cxx_atomic_base_impl<int> const*, std::__1::memory_order) (atomic:1006)
        std::__1::__atomic_base<int, false>::load(std::__1::memory_order) const (atomic:1615)
        int QAtomicOps<int>::loadRelaxed<int>(std::__1::atomic<int> const&) (qatomic_cxx11.h:239)
        QBasicAtomicInteger<int>::loadRelaxed() const (qbasicatomic.h:107)
        QtPrivate::RefCount::deref() (qrefcount.h:66)
        QHash<QString, QVariant>::~QHash() (qhash.h:250)
        QHash<QString, QVariant>::~QHash() (qhash.h:250)
        QRenderRule::~QRenderRule() (qstylesheetstyle.cpp:510)
        QRenderRule::~QRenderRule() (qstylesheetstyle.cpp:510)
        QHashData::free_helper(void (*)(QHashData::Node*)) (qhash.cpp:572)
        QHashData::free_helper(void (*)(QHashData::Node*)) (qhash.cpp:572)
        QHash<int, QHash<unsigned long long, QRenderRule>>::freeData(QHashData*) (qhash.h:619)
        QHash<int, QHash<unsigned long long, QRenderRule>>::~QHash() (qhash.h:250)
        QHash<int, QHash<unsigned long long, QRenderRule>>::~QHash() (qhash.h:250)
        QHashNode<QObject const*, QHash<int, QHash<unsigned long long, QRenderRule>>>::~QHashNode() (qhash.h:147)
        QHashNode<QObject const*, QHash<int, QHash<unsigned long long, QRenderRule>>>::~QHashNode() (qhash.h:147)
        QHash<QObject const*, QHash<int, QHash<unsigned long long, QRenderRule>>>::deleteNode2(QHashData::Node*) (qhash.h:595)
        QHash<QObject const*, QHash<int, QHash<unsigned long long, QRenderRule>>>::deleteNode(QHashNode<QObject const*, QHash<int, QHash<unsigned long long, QRenderRule>>>*) (qhash.h:585)
        QHash<QObject const*, QHash<int, QHash<unsigned long long, QRenderRule>>>::remove(QObject const* const&) (qhash.h:824)
        updateObjects(QList<QObject const*> const&) (qstylesheetstyle.cpp:2769)
        QStyleSheetStyle::repolish(QWidget*) (qstylesheetstyle.cpp:2969)
        

        So I changed to use QStyleSheetStyle::unpolish, hoping to reduce the occurrence of collapse. But occasionally there is a crash.

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Please provide a minimal, compilable example of your problem. Check it with a recent Qt6 version and if the issue still exists, create a bug report (or post it here and I'll take a look on it).

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved