Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-40644

Crash: Setting qobject property with QVariant() will cause crash

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.3.1
    • Core: Object Model
    • None
    • Any

    Description

      1) A test class with Q_PROPERTY in QSharedPointer<int>
      2) Setting the property with invalid QVariant will cause crash.

      TestCode attached.

      (test.h)
      typedef QSharedPointer<int> IntPtr2;
      Q_DECLARE_METATYPE(IntPtr2)
      
      class CTest : public QObject
      {
          Q_OBJECT
      public:
          Q_PROPERTY(IntPtr2 spine2 READ GetSpine2 WRITE SetSpine2)
      
          IntPtr2 GetSpine2() const
          {
              return m_Spine2;
          }
          void SetSpine2(IntPtr2 p_Spine2)
          {
              m_Spine2 = p_Spine2;
          }
      
       private:
          IntPtr2 m_Spine2;
      };
      
      main.cpp
      
      int main(int argc, char *argv[])
      {
          qRegisterMetaType<IntPtr2>();
      
          // QVariant var = qVariantFromValue(IntPtr2()); // works
          QVariant var;
      
          CTest test;
          test.setProperty("spine2", var);    // crash
      }
      

      crash log:
      0 bool QBasicAtomicOps<4>::ref<int>(int&) qatomic_x86.h 184 0x100002c00
      1 QBasicAtomicInteger<int>::ref() qbasicatomic.h 135 0x100002be5
      2 QSharedPointer<int>::ref() const qsharedpointer_impl.h 502 0x100002ba0
      3 QSharedPointer qsharedpointer_impl.h 322 0x100002b75
      4 QSharedPointer qsharedpointer_impl.h 322 0x100002add
      5 CTest::qt_metacall(QMetaObject::Call, int, void**) moc_CTest.cpp 108 0x100003379
      6 QMetaProperty::write(QObject*, QVariant const&) const QMetaProperty::write(QObject*, QVariant const&) const 0x1002512c5
      7 QObject::setProperty(char const*, QVariant const&) QObject::setProperty(char const*, QVariant const&) 0x10027983f
      8 main main.cpp 12 0x1000020c9
      9 start start 0x100002074

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-40644
          # Subject Branch Project Status CR V

          Activity

            People

              nierob Nierob
              simputest Dan Craft
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes