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

QtScript depends on hardcoded QObject metaobject layout

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.0.0
    • 5.0.0
    • Qt Script
    • None
    • 0ff8577a992b1d5c011b04e47ade84074cbd3034

    Description

      As of e1d4fabc5d2f7ec5a2f84a6c7c76cdb054552ca6, qtscript has some fragile dependencies on the layout of QObject's metaobject. It makes assumptions which are not verified at compile time or runtime, which can lead to incorrect behavior if QObject is changed (e.g. by adding/removing signals/slots).

      For example, this code:

      // src/script/bridge/qscriptqobject.cpp
       
       static bool hasMethodAccess(const QMetaMethod &method, int index, const QScriptEngine::QObjectWrapOptions &opt)
       {
           return (method.access() != QMetaMethod::Private)
               && ((index != 2) || !(opt & QScriptEngine::ExcludeDeleteLater))
               && (!(opt & QScriptEngine::ExcludeSlots) || (method.methodType() != QMetaMethod::Slot));
       }
      

      ...assumes that deleteLater() is the metamethod at index 2 in QObject's metaobject (which is actually false since qtbase ba635d7e74472f3a54c0c4686966af46d9035c6f).

      The tst_qscriptextqobject autotest also makes assumptions about QObject's metaobject, but I think this is OK (it seems the most practical way to write the test, and if the metaobject changes then the test starts to fail and can easily be updated).

      Attachments

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

        Activity

          People

            kenthans Kent Hansen (Inactive)
            rmcgover Rohan McGovern (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes