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

Crash in DSCameraControl when DSCameraSession status changes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.11.1, 5.11.2
    • Fix Version/s: 5.11.3
    • Component/s: Multimedia
    • Labels:
      None
    • Platform/s:
      Windows

      Description

      When destroying the QCamera we have crashes inside the DirectShow plugin for the camera (DSCameraControl)

       

      In previous versions the code was:

      DSCameraControl::DSCameraControl(QObject *parent)
      : QCameraControl(parent)
      , m_state(QCamera::UnloadedState)
      , m_captureMode(QCamera::CaptureStillImage)

      {     m_session = qobject_cast<DSCameraSession*>(parent);     connect(m_session, SIGNAL(statusChanged(QCamera::Status)),               this, SIGNAL(statusChanged(QCamera::Status))); }

      so the connection was implicitly destroyed when object was also destroyed.

       

      In version Qt5.11.1 & Qt5.11.2 this code has changed using a lamda function into:

      DSCameraControl::DSCameraControl(QObject *parent)
      : QCameraControl(parent)
      , m_state(QCamera::UnloadedState)
      , m_captureMode(QCamera::CaptureStillImage)
      {
           m_session = qobject_cast<DSCameraSession*>(parent);
           connect(m_session, &DSCameraSession::statusChanged,
                    [&](QCamera::Status status)

      {                        if (status == QCamera::UnloadedStatus)                              m_state = QCamera::UnloadedState;                        emit statusChanged(status);      }

      );
           connect(m_session, &DSCameraSession::cameraError,
                  this, &DSCameraControl::error);
      }

      So the lamda function is called even if the object is destroyed, hence the crash.

       

      A solution we found working is the modification below:

      DSCameraControl::DSCameraControl(QObject *parent)
      : QCameraControl(parent)
      , m_state(QCamera::UnloadedState)
      , m_captureMode(QCamera::CaptureStillImage)
      {
           m_session = qobject_cast<DSCameraSession*>(parent);
           connect(m_session, &DSCameraSession::statusChanged, this,
                    [&](QCamera::Status status)

      {                        if (status == QCamera::UnloadedStatus)                              m_state = QCamera::UnloadedState;                        emit statusChanged(status);      }

      );
           connect(m_session, &DSCameraSession::cameraError,
                  this, &DSCameraControl::error);
      }

       

        Attachments

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

          Activity

            People

            Assignee:
            valentyn.doroshchuk Valentyn Doroshchuk
            Reporter:
            iosif_hamlatzis Iosif Hamlatzis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes