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

qRegisterMetatype invalidates type check in setProperty

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 5.1.1
    • Core: Object Model
    • None
    • Linux, Windows

    Description

      QObject::setProperty normally checks that the passed-in type can be converted to the target type and doesn't call the setter function if it cannot. This works with user-defined variant types as well: if you pass a wrong type, the setter function won't be called at all.

      However, when the custom type is registered with qRegisterMetatype, the check no longer works. If you pass an object of a wrong type to setProperty, the setter function will be called with an object that is filled with zeros. This is fatal for example with classes that contain a d pointer.

      The attached project illustrates this. Commenting out qRegisterMetaType() solves the problem.

      Attachments

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              topiolli Topi Mäenpää
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes