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

ExecutionEngine::metaTypeFromJS and ExecutionEngine::toVariant are partly redundant

    XMLWordPrintable

Details

    Description

      toVariant() only performs "safe" conversions to the type given as hint and otherwise produces a variant of the "native" type of the JS value. Since everything can be wrapped in QVariant it never fails.

      metaTypeFromJS() tries to perform any kind of conversion and returns true if anything succeeds. It can fail and return false.

      There are two problems here:

      1. The code for the "safe" conversions is duplicated and incomplete in both locations.
      2. toVariant() produces a QVariant and allocates the data in the process. metaTypeFromJS() uses QMetaType (or some known copy-ctor) to copy the value to a location at a given pointer. It still requires there to be a pre-constructed value in that place (ie it does QMetaType::destruct() before constructing the new value). This needs unification.

      Ideally, we account for move-constructible types and assignment operators, too. That requires changes in QMetaType. For now, untangling this mess would be quite beneficial already.

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            ulherman Ulf Hermann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes