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

QSignalSpy ctor crashes if object is 0

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.0.0
    • 4.7.0
    • Testing: qtestlib
    • None
    • d9119535a2e3fcb977998ab1f7006f8a15b5a140

    Description

      This will crash (sorry, no backtracke this time - got problems with debug symbols)

      QObject *obj = 0;
      QSignalSpy spy(obj, SIGNAL(...));

      Of course in this example you could say it's easy to avoid the invalid object, But in tests, where you would setup your signal spys in the beginning (otherwise, you might miss signals already), it can easily happen that one of the participating objects is 0. And since I then have to avoid QSignalSpy construction alltogether, it means that my code would have to check for a valid QSignalSpy pointer first. And then heap allocation of QSignalSpy could lead to memory leaks etc ...

      In short: it would simply be more convenient if the ctor could deal with 0, and QSignalSpy::isValid could be used to check for both, valid signal and valid object (the former implies the latter, actually).

      Attachments

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

        Activity

          People

            jasmcdon Jason McDonald (Closed Nokia Identity. Please assign to "macadder" instead) (Inactive)
            mikhas Michael Hasselmann
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes