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

QCamera signalize about state change before real change was made

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.2.1
    • 5.2.0 Beta1
    • Multimedia
    • None
    • 9ceb1c083e4f6911ace1af3c9dfa6b4dd9036586

    Description

      Code from file qcamera.cpp:
      void QCameraPrivate::setState(QCamera::State newState)
      {
      ...
      state = newState;
      control->setState(state);
      emit q->stateChanged(state);
      }

      Looks correct, but we don't check if control's state was really changed. It may work for some platforms but on android there is following code in qandroidcamerasession.cpp:
      void QAndroidCameraSession::setState(QCamera::State state)
      {
      // If the application is inactive, the camera shouldn't be started. Save the desired state
      // instead and it will be set when the application becomes active.
      if (qApp->applicationState() != Qt::ApplicationActive)

      { m_savedState = state; return; }

      ...
      I.e. there is possible situations where state will not be changed, but code above generates signal. As result there is no way to start something just after camera activated because wrong signal which prevent work code depending on camera and starting by this signal.

      My fix which works for me:
      void QCameraPrivate::setState(QCamera::State newState)
      {
      ...
      /*
      state = newState;
      control->setState(state);
      emit q->stateChanged(state);
      */
      control->setState(newState);
      QCamera::State nState=control->state();
      if(nState != state)

      { state=nState; emit q->stateChanged(state); }

      }

      Attachments

        For Gerrit Dashboard: QTBUG-35070
        # Subject Branch Project Status CR V

        Activity

          People

            ylopes Yoann Lopes
            eskon2 Sergey Kondryukov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes