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:
parent
89080b949e
commit
9e55c77849
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user