2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* editor_resource_preview.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:11:45 +00:00
|
|
|
/* https://godotengine.org */
|
2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
2017-01-01 21:01:57 +00:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-07 22:45:00 +00:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2016-06-18 12:46:12 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2015-05-31 04:59:42 +00:00
|
|
|
#include "editor_resource_preview.h"
|
2017-03-18 23:36:26 +00:00
|
|
|
#include "editor_scale.h"
|
2015-05-31 04:59:42 +00:00
|
|
|
#include "editor_settings.h"
|
2017-03-18 23:36:26 +00:00
|
|
|
#include "globals.h"
|
2015-05-31 04:59:42 +00:00
|
|
|
#include "io/resource_loader.h"
|
|
|
|
#include "io/resource_saver.h"
|
2016-07-09 14:19:49 +00:00
|
|
|
#include "message_queue.h"
|
2017-03-18 23:36:26 +00:00
|
|
|
#include "os/file_access.h"
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String &p_path) {
|
2015-05-31 04:59:42 +00:00
|
|
|
|
|
|
|
RES res = ResourceLoader::load(p_path);
|
|
|
|
if (!res.is_valid())
|
|
|
|
return res;
|
|
|
|
return generate(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorResourcePreviewGenerator::EditorResourcePreviewGenerator() {
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
EditorResourcePreview *EditorResourcePreview::singleton = NULL;
|
2015-05-31 04:59:42 +00:00
|
|
|
|
|
|
|
void EditorResourcePreview::_thread_func(void *ud) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
EditorResourcePreview *erp = (EditorResourcePreview *)ud;
|
2015-05-31 04:59:42 +00:00
|
|
|
erp->_thread();
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Texture> &p_texture, ObjectID id, const StringName &p_func, const Variant &p_ud) {
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2015-06-06 12:44:38 +00:00
|
|
|
//print_line("preview is ready");
|
2015-05-31 04:59:42 +00:00
|
|
|
preview_mutex->lock();
|
|
|
|
|
2016-05-27 17:18:40 +00:00
|
|
|
String path = p_str;
|
2017-03-18 23:36:26 +00:00
|
|
|
uint32_t hash = 0;
|
|
|
|
uint64_t modified_time = 0;
|
2016-05-27 17:18:40 +00:00
|
|
|
|
|
|
|
if (p_str.begins_with("ID:")) {
|
2017-03-18 23:36:26 +00:00
|
|
|
hash = p_str.get_slicec(':', 2).to_int();
|
|
|
|
path = "ID:" + p_str.get_slicec(':', 1);
|
2016-07-03 16:15:15 +00:00
|
|
|
} else {
|
|
|
|
modified_time = FileAccess::get_modified_time(path);
|
2016-05-27 17:18:40 +00:00
|
|
|
}
|
|
|
|
|
2015-05-31 04:59:42 +00:00
|
|
|
Item item;
|
2017-03-18 23:36:26 +00:00
|
|
|
item.order = order++;
|
|
|
|
item.preview = p_texture;
|
|
|
|
item.last_hash = hash;
|
|
|
|
item.modified_time = modified_time;
|
2016-05-27 17:18:40 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
cache[path] = item;
|
2015-05-31 04:59:42 +00:00
|
|
|
|
|
|
|
preview_mutex->unlock();
|
2016-07-09 14:19:49 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
MessageQueue::get_singleton()->push_call(id, p_func, path, p_texture, p_ud);
|
2015-05-31 04:59:42 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem &p_item, const String &cache_base) {
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2016-05-27 17:18:40 +00:00
|
|
|
String type;
|
|
|
|
|
|
|
|
if (p_item.resource.is_valid())
|
2017-03-18 23:36:26 +00:00
|
|
|
type = p_item.resource->get_type();
|
2016-05-27 17:18:40 +00:00
|
|
|
else
|
2017-03-18 23:36:26 +00:00
|
|
|
type = ResourceLoader::get_resource_type(p_item.path);
|
2015-06-06 12:44:38 +00:00
|
|
|
//print_line("resource type is: "+type);
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (type == "")
|
2015-05-31 04:59:42 +00:00
|
|
|
return Ref<Texture>(); //could not guess type
|
|
|
|
|
|
|
|
Ref<Texture> generated;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < preview_generators.size(); i++) {
|
2016-07-09 14:19:49 +00:00
|
|
|
|
2015-05-31 04:59:42 +00:00
|
|
|
if (!preview_generators[i]->handles(type))
|
|
|
|
continue;
|
2016-05-27 17:18:40 +00:00
|
|
|
if (p_item.resource.is_valid()) {
|
|
|
|
generated = preview_generators[i]->generate(p_item.resource);
|
|
|
|
} else {
|
|
|
|
generated = preview_generators[i]->generate_from_path(p_item.path);
|
|
|
|
}
|
2015-05-31 04:59:42 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-05-27 17:18:40 +00:00
|
|
|
if (!p_item.resource.is_valid()) {
|
|
|
|
// cache the preview in case it's a resource on disk
|
|
|
|
if (generated.is_valid()) {
|
|
|
|
//print_line("was generated");
|
|
|
|
int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
|
2017-03-18 23:36:26 +00:00
|
|
|
thumbnail_size *= EDSCALE;
|
2016-05-27 17:18:40 +00:00
|
|
|
//wow it generated a preview... save cache
|
2017-03-18 23:36:26 +00:00
|
|
|
ResourceSaver::save(cache_base + ".png", generated);
|
|
|
|
FileAccess *f = FileAccess::open(cache_base + ".txt", FileAccess::WRITE);
|
2016-05-27 17:18:40 +00:00
|
|
|
f->store_line(itos(thumbnail_size));
|
|
|
|
f->store_line(itos(FileAccess::get_modified_time(p_item.path)));
|
|
|
|
f->store_line(FileAccess::get_md5(p_item.path));
|
|
|
|
memdelete(f);
|
|
|
|
} else {
|
|
|
|
//print_line("was not generated");
|
|
|
|
}
|
2015-05-31 04:59:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return generated;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorResourcePreview::_thread() {
|
|
|
|
|
2015-06-06 12:44:38 +00:00
|
|
|
//print_line("begin thread");
|
2017-03-18 23:36:26 +00:00
|
|
|
while (!exit) {
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2015-06-06 12:44:38 +00:00
|
|
|
//print_line("wait for semaphore");
|
2015-05-31 04:59:42 +00:00
|
|
|
preview_sem->wait();
|
|
|
|
preview_mutex->lock();
|
|
|
|
|
2015-06-06 12:44:38 +00:00
|
|
|
//print_line("blue team go");
|
2015-05-31 04:59:42 +00:00
|
|
|
|
|
|
|
if (queue.size()) {
|
|
|
|
|
|
|
|
QueueItem item = queue.front()->get();
|
|
|
|
queue.pop_front();
|
|
|
|
|
|
|
|
if (cache.has(item.path)) {
|
|
|
|
//already has it because someone loaded it, just let it know it's ready
|
2016-05-27 17:18:40 +00:00
|
|
|
if (item.resource.is_valid()) {
|
2017-03-18 23:36:26 +00:00
|
|
|
item.path += ":" + itos(cache[item.path].last_hash); //keep last hash (see description of what this is in condition below)
|
2016-05-27 17:18:40 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
_preview_ready(item.path, cache[item.path].preview, item.id, item.function, item.userdata);
|
2016-05-27 17:18:40 +00:00
|
|
|
|
2016-07-09 14:19:49 +00:00
|
|
|
preview_mutex->unlock();
|
2015-05-31 04:59:42 +00:00
|
|
|
} else {
|
2016-07-09 14:19:49 +00:00
|
|
|
preview_mutex->unlock();
|
|
|
|
|
|
|
|
Ref<Texture> texture;
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2016-07-09 14:19:49 +00:00
|
|
|
//print_line("pop from queue "+item.path);
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2016-07-09 14:19:49 +00:00
|
|
|
int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
|
2017-03-18 23:36:26 +00:00
|
|
|
thumbnail_size *= EDSCALE;
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (item.resource.is_valid()) {
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
texture = _generate_preview(item, String());
|
2016-07-09 14:19:49 +00:00
|
|
|
//adding hash to the end of path (should be ID:<objid>:<hash>) because of 5 argument limit to call_deferred
|
2017-03-18 23:36:26 +00:00
|
|
|
_preview_ready(item.path + ":" + itos(item.resource->hash_edited_version()), texture, item.id, item.function, item.userdata);
|
2015-05-31 04:59:42 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String temp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp");
|
2016-07-09 14:19:49 +00:00
|
|
|
String cache_base = Globals::get_singleton()->globalize_path(item.path).md5_text();
|
2017-03-18 23:36:26 +00:00
|
|
|
cache_base = temp_path.plus_file("resthumb-" + cache_base);
|
2016-07-09 14:19:49 +00:00
|
|
|
|
|
|
|
//does not have it, try to load a cached thumbnail
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String file = cache_base + ".txt";
|
2016-07-09 14:19:49 +00:00
|
|
|
//print_line("cachetxt at "+file);
|
2017-03-18 23:36:26 +00:00
|
|
|
FileAccess *f = FileAccess::open(file, FileAccess::READ);
|
2016-07-09 14:19:49 +00:00
|
|
|
if (!f) {
|
|
|
|
|
|
|
|
//print_line("generate because not cached");
|
|
|
|
|
|
|
|
//generate
|
2017-03-18 23:36:26 +00:00
|
|
|
texture = _generate_preview(item, cache_base);
|
2016-07-09 14:19:49 +00:00
|
|
|
} else {
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2016-07-09 14:19:49 +00:00
|
|
|
uint64_t modtime = FileAccess::get_modified_time(item.path);
|
|
|
|
int tsize = f->get_line().to_int64();
|
|
|
|
uint64_t last_modtime = f->get_line().to_int64();
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2016-07-09 14:19:49 +00:00
|
|
|
bool cache_valid = true;
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (tsize != thumbnail_size) {
|
|
|
|
cache_valid = false;
|
2016-07-09 14:19:49 +00:00
|
|
|
memdelete(f);
|
2017-03-18 23:36:26 +00:00
|
|
|
} else if (last_modtime != modtime) {
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2016-07-09 14:19:49 +00:00
|
|
|
String last_md5 = f->get_line();
|
|
|
|
String md5 = FileAccess::get_md5(item.path);
|
|
|
|
memdelete(f);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (last_md5 != md5) {
|
2016-07-09 14:19:49 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
cache_valid = false;
|
2016-07-09 14:19:49 +00:00
|
|
|
} else {
|
|
|
|
//update modified time
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
f = FileAccess::open(file, FileAccess::WRITE);
|
2016-07-09 14:19:49 +00:00
|
|
|
f->store_line(itos(modtime));
|
|
|
|
f->store_line(md5);
|
|
|
|
memdelete(f);
|
|
|
|
}
|
|
|
|
} else {
|
2015-05-31 04:59:42 +00:00
|
|
|
memdelete(f);
|
|
|
|
}
|
|
|
|
|
2016-07-09 14:19:49 +00:00
|
|
|
if (cache_valid) {
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
texture = ResourceLoader::load(cache_base + ".png", "ImageTexture", true);
|
2016-07-09 14:19:49 +00:00
|
|
|
if (!texture.is_valid()) {
|
|
|
|
//well fuck
|
2017-03-18 23:36:26 +00:00
|
|
|
cache_valid = false;
|
2016-07-09 14:19:49 +00:00
|
|
|
}
|
2015-05-31 04:59:42 +00:00
|
|
|
}
|
|
|
|
|
2016-07-09 14:19:49 +00:00
|
|
|
if (!cache_valid) {
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
texture = _generate_preview(item, cache_base);
|
2016-07-09 14:19:49 +00:00
|
|
|
}
|
|
|
|
}
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2016-07-09 14:19:49 +00:00
|
|
|
//print_line("notify of preview ready");
|
2017-03-18 23:36:26 +00:00
|
|
|
_preview_ready(item.path, texture, item.id, item.function, item.userdata);
|
2016-07-09 14:19:49 +00:00
|
|
|
}
|
2015-05-31 04:59:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
preview_mutex->unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p_res, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata) {
|
2016-05-27 17:18:40 +00:00
|
|
|
|
|
|
|
ERR_FAIL_NULL(p_receiver);
|
|
|
|
ERR_FAIL_COND(!p_res.is_valid());
|
|
|
|
|
|
|
|
preview_mutex->lock();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String path_id = "ID:" + itos(p_res->get_instance_ID());
|
2016-07-03 16:15:15 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cache.has(path_id) && cache[path_id].last_hash == p_res->hash_edited_version()) {
|
2016-07-03 16:15:15 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
cache[path_id].order = order++;
|
|
|
|
p_receiver->call_deferred(p_receiver_func, path_id, cache[path_id].preview, p_userdata);
|
2016-05-27 17:18:40 +00:00
|
|
|
preview_mutex->unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-03 16:15:15 +00:00
|
|
|
cache.erase(path_id); //erase if exists, since it will be regen
|
|
|
|
|
2016-05-27 17:18:40 +00:00
|
|
|
//print_line("send to thread "+p_path);
|
|
|
|
QueueItem item;
|
2017-03-18 23:36:26 +00:00
|
|
|
item.function = p_receiver_func;
|
|
|
|
item.id = p_receiver->get_instance_ID();
|
|
|
|
item.resource = p_res;
|
|
|
|
item.path = path_id;
|
|
|
|
item.userdata = p_userdata;
|
2016-05-27 17:18:40 +00:00
|
|
|
|
|
|
|
queue.push_back(item);
|
|
|
|
preview_mutex->unlock();
|
|
|
|
preview_sem->post();
|
|
|
|
}
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorResourcePreview::queue_resource_preview(const String &p_path, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata) {
|
2015-05-31 04:59:42 +00:00
|
|
|
|
|
|
|
ERR_FAIL_NULL(p_receiver);
|
|
|
|
preview_mutex->lock();
|
|
|
|
if (cache.has(p_path)) {
|
2017-03-18 23:36:26 +00:00
|
|
|
cache[p_path].order = order++;
|
|
|
|
p_receiver->call_deferred(p_receiver_func, p_path, cache[p_path].preview, p_userdata);
|
2015-05-31 04:59:42 +00:00
|
|
|
preview_mutex->unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-07 01:06:58 +00:00
|
|
|
//print_line("send to thread "+p_path);
|
2015-05-31 04:59:42 +00:00
|
|
|
QueueItem item;
|
2017-03-18 23:36:26 +00:00
|
|
|
item.function = p_receiver_func;
|
|
|
|
item.id = p_receiver->get_instance_ID();
|
|
|
|
item.path = p_path;
|
|
|
|
item.userdata = p_userdata;
|
2015-05-31 04:59:42 +00:00
|
|
|
|
|
|
|
queue.push_back(item);
|
|
|
|
preview_mutex->unlock();
|
|
|
|
preview_sem->post();
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorResourcePreview::add_preview_generator(const Ref<EditorResourcePreviewGenerator> &p_generator) {
|
2015-05-31 04:59:42 +00:00
|
|
|
|
|
|
|
preview_generators.push_back(p_generator);
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
EditorResourcePreview *EditorResourcePreview::get_singleton() {
|
2015-05-31 04:59:42 +00:00
|
|
|
|
|
|
|
return singleton;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorResourcePreview::_bind_methods() {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
ObjectTypeDB::bind_method("_preview_ready", &EditorResourcePreview::_preview_ready);
|
|
|
|
ObjectTypeDB::bind_method(_MD("check_for_invalidation", "path"), &EditorResourcePreview::check_for_invalidation);
|
2016-07-03 16:15:15 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
ADD_SIGNAL(MethodInfo("preview_invalidated", PropertyInfo(Variant::STRING, "path")));
|
2016-07-03 16:15:15 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorResourcePreview::check_for_invalidation(const String &p_path) {
|
2016-07-03 16:15:15 +00:00
|
|
|
|
|
|
|
preview_mutex->lock();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
bool call_invalidated = false;
|
2016-07-03 16:15:15 +00:00
|
|
|
if (cache.has(p_path)) {
|
|
|
|
|
|
|
|
uint64_t modified_time = FileAccess::get_modified_time(p_path);
|
2017-03-18 23:36:26 +00:00
|
|
|
if (modified_time != cache[p_path].modified_time) {
|
2016-07-03 16:15:15 +00:00
|
|
|
cache.erase(p_path);
|
2017-03-18 23:36:26 +00:00
|
|
|
call_invalidated = true;
|
2016-07-03 16:15:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
preview_mutex->unlock();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (call_invalidated) { //do outside mutex
|
|
|
|
call_deferred("emit_signal", "preview_invalidated", p_path);
|
2016-07-03 16:15:15 +00:00
|
|
|
}
|
2015-05-31 04:59:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorResourcePreview::EditorResourcePreview() {
|
2017-03-18 23:36:26 +00:00
|
|
|
singleton = this;
|
2015-05-31 04:59:42 +00:00
|
|
|
preview_mutex = Mutex::create();
|
2017-03-18 23:36:26 +00:00
|
|
|
preview_sem = Semaphore::create();
|
|
|
|
order = 0;
|
|
|
|
exit = false;
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
thread = Thread::create(_thread_func, this);
|
2015-05-31 04:59:42 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
EditorResourcePreview::~EditorResourcePreview() {
|
2015-05-31 04:59:42 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
exit = true;
|
2015-05-31 04:59:42 +00:00
|
|
|
preview_sem->post();
|
|
|
|
Thread::wait_to_finish(thread);
|
|
|
|
memdelete(thread);
|
|
|
|
memdelete(preview_mutex);
|
|
|
|
memdelete(preview_sem);
|
|
|
|
}
|