Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1246

Shiboken fails to detect polymorphic base class with a virtual destructor

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 5.14.1
    • Shiboken
    • None
    • macOS
    • 2e5cdd6bd8e99544fd9370900d30edda2c05c6f9 (pyside/pyside-setup/5.14)

    Description

      I am wrapping a C++/Python API where quite a number of classes inherit from the same (polymorphic) base class. An example:

      class PolymorphicBaseClass {
      public:
        PolymorphicBaseClass() = default;
        virtual ~PolymorphicBaseClass() = default;
      
        /* Workaround:
        virtual dummyMethodForShiboken() {
          Instead of having to write a lot of polymorphic-id-expressions,
          one can write a dummy virtual method in PolymorphicBaseClass.
          and shiboken sees it as polymorphic.
        }
        */
      
        void doSomething() {}
      };
      
      class InheritedClass : public PolymorphicBaseClass {
      public:
        InheritedClass() = default;
      
        void doSomethingElse();
      }; 
      

      During CPython code generation shiboken outputs warnings like:

      qt.shiboken: (typesystem) InheritedClass inherits from a non polymorphic type (PolymorphicBaseClass), type discovery based on RTTI is impossible, write a polymorphic-id-expression for this type.
      

      Using the workaround mentioned in above example code will silence this warning. More important possible failures on the Python side are reduced.

      Attachments

        1. 0001-Reproduce-PYSIDE-1246.patch
          3 kB
          Friedemann Kleint
        2. pyside1246_diag.diff
          3 kB
          Friedemann Kleint
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            antis81 Nils Fenner
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes