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

Crash in DSCameraControl when DSCameraSession status changes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.11.3
    • 5.11.1, 5.11.2
    • Multimedia
    • None
    • 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

            valentyn.doroshchuk Valentyn Doroshchuk
            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