Fixed crash when QCameraImageCapture is deleted before QMediaRecorder.

Change-Id: I3bbb87f03f122378e9367e1f2c0cc5b61fce6ed7
Reviewed-on: http://codereview.qt.nokia.com/3550
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
Dmytro Poplavskiy
2011-08-25 13:56:05 +10:00
committed by Qt by Nokia
parent ba62df130c
commit 47a5dd4371
3 changed files with 38 additions and 0 deletions

View File

@@ -109,6 +109,7 @@ public:
void _q_error(int id, int error, const QString &errorString);
void _q_readyChanged(bool);
void _q_serviceDestroyed();
void unsetError() { error = QCameraImageCapture::NoError; errorString.clear(); }
@@ -141,6 +142,14 @@ void QCameraImageCapturePrivate::_q_readyChanged(bool ready)
emit q->readyForCaptureChanged(ready);
}
void QCameraImageCapturePrivate::_q_serviceDestroyed()
{
mediaObject = 0;
control = 0;
encoderControl = 0;
captureDestinationControl = 0;
bufferFormatControl = 0;
}
/*!
Constructs a media recorder which records the media produced by \a mediaObject.
@@ -225,6 +234,8 @@ bool QCameraImageCapture::setMediaObject(QMediaObject *mediaObject)
service->releaseControl(d->captureDestinationControl);
if (d->bufferFormatControl)
service->releaseControl(d->bufferFormatControl);
disconnect(service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed()));
}
}
@@ -269,6 +280,8 @@ bool QCameraImageCapture::setMediaObject(QMediaObject *mediaObject)
this, SIGNAL(bufferFormatChanged(QVideoFrame::PixelFormat)));
}
connect(service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed()));
return true;
}
}

View File

@@ -145,6 +145,7 @@ private:
Q_DECLARE_PRIVATE(QCameraImageCapture)
Q_PRIVATE_SLOT(d_func(), void _q_error(int, int, const QString &))
Q_PRIVATE_SLOT(d_func(), void _q_readyChanged(bool))
Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed())
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraImageCapture::CaptureDestinations)