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

QtWebKit: QVariant and JS Array function arguments

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.3.2
    • 4.7.4, 4.8.x, 5.3.1
    • WebKit
    • None
    • 13f80d34ae84c3231118c8013beee55badab8929

    Description

      Creating some class

      CWkStuff.cpp
      class CWkStuff: public QObject
      {
         Q_OBJECT
      
      public:
         Q_INVOKABLE QVariant doSome(const QVariant &data) const
         {
            qDebug() << data;
      
            return data;
         };
      }; // class
      

      And use this method in JavaScript

      CWkStuff.doSome("hello");                 // done
      CWkStuff.doSome({});                      // done
      CWkStuff.doSome({a: 23, b: {q: [1, 2]}}); // done
      
      CWkStuff.doSome([]);                      // FAILS!
         // incompatible type of argument(s) in call to doSome(); candidates were
         //     doSome(QVariant)
      

      but if I using

      CWkStuff.cpp
       Q_INVOKABLE QVariant doSome(const QVariantList &data) const
      

      it's work done. (Without support Map or other types)

      That bug from qt_runtime.cpp:641

      qt_runtime.cpp
      // in function 'convertValueToQVariant' we contain visited object some like that
          if (value.isObject()) {
              object = value.toObject(exec);
              if (visitedObjects->contains(object))
                  return QVariant();
      
              visitedObjects->add(object);
          }
      
      /* ... */
      
         // But checking for recursive call some like that
      
         if (type == Object) { // may be using `value.isObject()` here
             // Since we haven't really visited this object yet, we remove it
             visitedObjects->remove(object);
         }
      

      Attachments

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

        Activity

          People

            allan.jensen Allan Sandfeld Jensen
            disable13 Sergey Timoschenko
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes