Flush stuff pending on visual server thread when exiting, fixes #24669
This commit is contained in:
parent
856c36cb89
commit
abbca3b3cc
2 changed files with 10 additions and 1 deletions
|
@ -313,6 +313,8 @@ void EditorResourcePreview::_thread() {
|
|||
preview_mutex->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
exited = true;
|
||||
}
|
||||
|
||||
void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p_res, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata) {
|
||||
|
@ -420,11 +422,16 @@ void EditorResourcePreview::check_for_invalidation(const String &p_path) {
|
|||
void EditorResourcePreview::start() {
|
||||
ERR_FAIL_COND(thread);
|
||||
thread = Thread::create(_thread_func, this);
|
||||
exited = false;
|
||||
}
|
||||
void EditorResourcePreview::stop() {
|
||||
if (thread) {
|
||||
exit = true;
|
||||
preview_sem->post();
|
||||
while (!exited) {
|
||||
OS::get_singleton()->delay_usec(10000);
|
||||
VisualServer::get_singleton()->sync(); //sync pending stuff, as thread may be blocked on visual server
|
||||
}
|
||||
Thread::wait_to_finish(thread);
|
||||
memdelete(thread);
|
||||
thread = NULL;
|
||||
|
@ -438,6 +445,7 @@ EditorResourcePreview::EditorResourcePreview() {
|
|||
preview_sem = Semaphore::create();
|
||||
order = 0;
|
||||
exit = false;
|
||||
exited = false;
|
||||
}
|
||||
|
||||
EditorResourcePreview::~EditorResourcePreview() {
|
||||
|
|
|
@ -90,7 +90,8 @@ class EditorResourcePreview : public Node {
|
|||
Mutex *preview_mutex;
|
||||
Semaphore *preview_sem;
|
||||
Thread *thread;
|
||||
bool exit;
|
||||
volatile bool exit;
|
||||
volatile bool exited;
|
||||
|
||||
struct Item {
|
||||
Ref<Texture> preview;
|
||||
|
|
Loading…
Reference in a new issue