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

QtScript should emit a warning for invalid signal declarations

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 4.6.0
    • 4.4.2
    • Qt Script
    • None

      I created a QObject child class, namely A.
      Here's a summary:
      class A : public QObject
      {
      Q_OBJECT;
      signals:
      void bleep(myCustomType&);
      }

      Instances of A are then registered into a QScriptEngine. myCustomType is a registered MetaType, and conversions functions were made available using qScriptRegisterMetaType().

      I expected to be able to use MyCustomType converted to a ScriptValue while connecting a script function to the signal. Oviously things didn't work because the script function parameter was an empty QVariant.

      I expected to see an error or a warning at some point, either from the script engine or from the moc, since having a by-reference signal parameter is, as far as I know, an undocumented pitfall.

      The fact that the signal argument is passed by reference somehow prevents the conversion functions registered with qScriptRegisterMetaType() to be called. This results in an empty QVariant() resulting of the failed conversion.

      Removing the reference signal parameter and using a plain signal parameter, providing copy semantics are available, solves the problem.

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

            kenthans Kent Hansen (Inactive)
            janichol Andy Nichols
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes