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

Shiboken fails on enum conversion when used as default parameter

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • None
    • 5.13.2
    • PySide
    • None
    • All

    Description

      Having to deal with class/member declarations like this:

      class MyClass : public QObject {
      Q_OBJECT
      public:
        enum MyEnum { One, Two, Three }; // not using enum class here
        Q_ENUM(MyEnum);
      public:
        MyClass(QObject* parent = 0);
      
        Q_INVOKABLE void doSomethingWithEnum(int my_enum = One); // <-- shiboken fails here
      };
      
      // function definitions for completeness (originally in cpp file)
      MyClass::MyClass(QObject* parent) : QObject(parent) {}
      MyClass::doSomethingWithEnum(int my_enum) { /* do something with it */ }
      

      The code generated by Shiboken fails to compile (type lookup fails) and looks similar to this (from my head):

      void sbk_wrapped_my_class_do_something_with_enum(/* PyObject etc. */) {
        // only the relevant code
        PyInt tmp_value = MyEnum::One; // not sure the type is correct, but it doesn't matter here
        // --> should be MyClass::One (or MyClass::MyEnum::One for an enum class)
      }
      

      (Looking at it again the default parameter declaration is actually wrong and should read "MyClass::One". Don't know why, but original C++ code actually compiles with this.)
      Edit: Same results with fixed code.

      However users can solve (workaround) this by removing the default parameter assignment from the method declaration.

      Attachments

        1. pyside1161_repro.diff
          1 kB
          Friedemann Kleint

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              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