Commit 78aea376 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

disconnect to avoid crashes on exit

parent e0c091f3
......@@ -162,8 +162,10 @@ bool VideoFrameGrabber::present(const QVideoFrame &input_frame)
return true;
}
class dtkVisualizationViewVideoPlayerPrivate
class dtkVisualizationViewVideoPlayerPrivate: public QObject
{
Q_OBJECT
public:
dtkVisualizationViewVideoPlayerPrivate(QObject *parent);
~dtkVisualizationViewVideoPlayerPrivate(void);
......@@ -178,6 +180,9 @@ public:
dtkWidgetsOverlayPane *overlay = nullptr;
dtkWidgetsHUD *hud = nullptr;
public slots:
void onStateChanged(QMediaPlayer::State);
public:
int hide_timer = 5000;
......@@ -188,7 +193,6 @@ public:
dtkVisualizationViewVideoPlayerPrivate::dtkVisualizationViewVideoPlayerPrivate(QObject *parent)
{
this->grabber = new VideoFrameGrabber(parent);
this->player = new QMediaPlayer(parent);
this->player->setAudioRole(QAudio::VideoRole); // ?
......@@ -197,10 +201,20 @@ dtkVisualizationViewVideoPlayerPrivate::dtkVisualizationViewVideoPlayerPrivate(Q
dtkVisualizationViewVideoPlayerPrivate::~dtkVisualizationViewVideoPlayerPrivate(void)
{
delete player;
delete grabber;
disconnect(controls, &dtkVisualizationWidgetsVideoControls::pause, player, &QMediaPlayer::pause);
disconnect(controls, &dtkVisualizationWidgetsVideoControls::play, player, &QMediaPlayer::play);
disconnect(controls, &dtkVisualizationWidgetsVideoControls::seekTo, player, &QMediaPlayer::setPosition);
disconnect(player, &QMediaPlayer::stateChanged, this, &dtkVisualizationViewVideoPlayerPrivate::onStateChanged);
}
void dtkVisualizationViewVideoPlayerPrivate::onStateChanged(QMediaPlayer::State state)
{
if (state == QMediaPlayer::StoppedState)
this->controls->toggle();
}
dtkVisualizationViewVideoPlayer::dtkVisualizationViewVideoPlayer(QWidget *parent): ViewVideo(parent)
{
d = new dtkVisualizationViewVideoPlayerPrivate(this);
......@@ -237,6 +251,7 @@ dtkVisualizationViewVideoPlayer::dtkVisualizationViewVideoPlayer(QWidget *parent
connect(d->player, &QMediaPlayer::durationChanged, d->controls, &dtkVisualizationWidgetsVideoControls::setDuration);
connect(d->player, &QMediaPlayer::positionChanged, d->controls, &dtkVisualizationWidgetsVideoControls::setPosition);
connect(d->player, &QMediaPlayer::stateChanged, d, &dtkVisualizationViewVideoPlayerPrivate::onStateChanged);
connect(d->controls, &dtkVisualizationWidgetsVideoControls::pause, d->player, &QMediaPlayer::pause);
connect(d->controls, &dtkVisualizationWidgetsVideoControls::play, d->player, &QMediaPlayer::play);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment