diff --git a/src/video/netcamview.cpp b/src/video/netcamview.cpp index b6e1c29d0..997bbfe0a 100644 --- a/src/video/netcamview.cpp +++ b/src/video/netcamview.cpp @@ -56,16 +56,16 @@ NetCamView::NetCamView(int friendId, QWidget* parent) frameLayout->setMargin(0); updateRatio(); - connect(selfVideoSurface, &VideoSurface::ratioChanged, this, &NetCamView::updateRatio); + connections += connect(selfVideoSurface, &VideoSurface::ratioChanged, this, &NetCamView::updateRatio); - connect(videoSurface, &VideoSurface::boundaryChanged, [this]() + connections += connect(videoSurface, &VideoSurface::boundaryChanged, [this]() { QRect boundingRect = videoSurface->getBoundingRect(); updateFrameSize(boundingRect.size()); selfFrame->setBoundary(boundingRect); }); - connect(videoSurface, &VideoSurface::ratioChanged, [this]() + connections += connect(videoSurface, &VideoSurface::ratioChanged, [this]() { selfFrame->setMinimumWidth(selfFrame->minimumHeight() * selfVideoSurface->getRatio()); QRect boundingRect = videoSurface->getBoundingRect(); @@ -73,12 +73,12 @@ NetCamView::NetCamView(int friendId, QWidget* parent) selfFrame->resetBoundary(boundingRect); }); - connect(Core::getInstance(), &Core::selfAvatarChanged, [this](const QPixmap& pixmap) + connections += connect(Core::getInstance(), &Core::selfAvatarChanged, [this](const QPixmap& pixmap) { selfVideoSurface->setAvatar(pixmap); }); - connect(Core::getInstance(), &Core::friendAvatarChanged, [this](int FriendId, const QPixmap& pixmap) + connections += connect(Core::getInstance(), &Core::friendAvatarChanged, [this](int FriendId, const QPixmap& pixmap) { if (this->friendId == FriendId) videoSurface->setAvatar(pixmap); @@ -92,6 +92,12 @@ NetCamView::NetCamView(int friendId, QWidget* parent) videoMode.FPS = Settings::getInstance().getCamVideoFPS(); } +NetCamView::~NetCamView() +{ + for (QMetaObject::Connection conn : connections) + disconnect(conn); +} + void NetCamView::show(VideoSource *source, const QString &title) { setSource(source); diff --git a/src/video/netcamview.h b/src/video/netcamview.h index 2aa1309c7..79e72fc4d 100644 --- a/src/video/netcamview.h +++ b/src/video/netcamview.h @@ -21,6 +21,7 @@ #define NETCAMVIEW_H #include "genericnetcamview.h" +#include class QHBoxLayout; struct vpx_image; @@ -34,6 +35,7 @@ class NetCamView : public GenericNetCamView public: NetCamView(int friendId, QWidget *parent=0); + ~NetCamView(); virtual void show(VideoSource* source, const QString& title); virtual void hide(); @@ -54,6 +56,7 @@ private: MovableWidget* selfFrame; int friendId; bool e = false; + QVector connections; }; #endif // NETCAMVIEW_H