cellCamera: fix qt handler crash if object is destroyed from another thread

This commit is contained in:
Megamouse 2021-10-24 14:48:28 +02:00
parent be972f04ac
commit 5e436984a2
1 changed files with 19 additions and 1 deletions

View File

@ -1,7 +1,9 @@
#include "stdafx.h" #include "stdafx.h"
#include "qt_camera_handler.h" #include "qt_camera_handler.h"
#include "Emu/system_config.h" #include "Emu/system_config.h"
#include "Emu/System.h"
#include "Emu/Io/camera_config.h" #include "Emu/Io/camera_config.h"
#include "Emu/Cell/lv2/sys_event.h"
#include <QMediaService> #include <QMediaService>
#include <QCameraInfo> #include <QCameraInfo>
@ -20,8 +22,24 @@ qt_camera_handler::qt_camera_handler() : camera_handler_base()
} }
qt_camera_handler::~qt_camera_handler() qt_camera_handler::~qt_camera_handler()
{
atomic_t<bool> wake_up = false;
Emu.CallAfter([&]()
{ {
close_camera(); close_camera();
m_surface.reset();
m_camera.reset();
m_error_handler.reset();
wake_up = true;
wake_up.notify_one();
});
while (!wake_up)
{
thread_ctrl::wait_on(wake_up, false);
}
} }
void qt_camera_handler::set_camera(const QCameraInfo& camera_info) void qt_camera_handler::set_camera(const QCameraInfo& camera_info)