1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Better freeing of CameraSource

This commit is contained in:
tux3 2015-06-26 19:04:53 +02:00
parent 89080b949e
commit 9e55c77849
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
3 changed files with 14 additions and 0 deletions

View File

@ -28,6 +28,7 @@
#include "src/persistence/profilelocker.h"
#include "src/widget/loginscreen.h"
#include "src/widget/translator.h"
#include "src/video/camerasource.h"
#include <QApplication>
#include <QCommandLineParser>
#include <QDateTime>
@ -275,6 +276,7 @@ int main(int argc, char *argv[])
logFile = nullptr;
#endif
CameraSource::destroyInstance();
Nexus::destroyInstance();
Settings::destroyInstance();
qDebug() << "Clean exit with status"<<errorcode;

View File

@ -51,6 +51,15 @@ CameraSource& CameraSource::getInstance()
return *instance;
}
void CameraSource::destroyInstance()
{
if (instance)
{
delete instance;
instance = nullptr;
}
}
void CameraSource::open()
{
open(CameraDevice::getDefaultDeviceName());
@ -293,6 +302,8 @@ void CameraSource::closeDevice()
continue;
vframe->releaseFrame();
}
freelist.clear();
freelist.squeeze();
// Free our resources and close the device
videoStreamIndex = -1;

View File

@ -47,6 +47,7 @@ class CameraSource : public VideoSource
Q_OBJECT
public:
static CameraSource& getInstance();
static void destroyInstance();
/// Opens the source for the camera device in argument, in the settings, or the system default
/// If a device is already open, the source will seamlessly switch to the new device
void open();