Fix behaviour of VideoWidget and SnapshotTaker

Stop video player when leaving a page and before deleting the
video widget. Do not leak the video player inside the SnapshotTaker.
This commit is contained in:
Tobias Koenig 2012-09-28 10:11:13 +02:00
parent ea08b46308
commit 906b7d5931
3 changed files with 15 additions and 1 deletions

View file

@ -27,6 +27,12 @@ SnapshotTaker::SnapshotTaker( const QString &url, QObject *parent )
m_player->play();
}
SnapshotTaker::~SnapshotTaker()
{
m_player->stop();
delete m_player;
}
void SnapshotTaker::stateChanged(Phonon::State newState, Phonon::State)
{
if (newState == Phonon::PlayingState) {

View file

@ -22,6 +22,7 @@ class SnapshotTaker : public QObject
public:
SnapshotTaker( const QString &url, QObject *parent = 0 );
~SnapshotTaker();
Q_SIGNALS:
void finished( const QImage &image );

View file

@ -59,10 +59,16 @@ class VideoWidget::Private
{
public:
Private( Okular::MovieAnnotation *ma, Okular::Document *doc, VideoWidget *qq )
: q( qq ), anno( ma ), document( doc ), loaded( false )
: q( qq ), anno( ma ), document( doc ), player( 0 ), loaded( false )
{
}
~Private()
{
if ( player )
player->stop();
}
enum PlayPauseMode { PlayMode, PauseMode };
void load();
@ -344,6 +350,7 @@ void VideoWidget::pageEntered()
void VideoWidget::pageLeft()
{
d->player->stop();
d->videoStopped();
hide();