summaryrefslogtreecommitdiff
path: root/editor/fileserver
diff options
context:
space:
mode:
Diffstat (limited to 'editor/fileserver')
-rw-r--r--editor/fileserver/editor_file_server.cpp17
-rw-r--r--editor/fileserver/editor_file_server.h2
2 files changed, 9 insertions, 10 deletions
diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp
index af7eb0c4c7..fb44c145b2 100644
--- a/editor/fileserver/editor_file_server.cpp
+++ b/editor/fileserver/editor_file_server.cpp
@@ -42,9 +42,10 @@
void EditorFileServer::_close_client(ClientData *cd) {
cd->connection->disconnect_from_host();
- cd->efs->wait_mutex->lock();
- cd->efs->to_wait.insert(cd->thread);
- cd->efs->wait_mutex->unlock();
+ {
+ MutexLock lock(cd->efs->wait_mutex);
+ cd->efs->to_wait.insert(cd->thread);
+ }
while (cd->files.size()) {
memdelete(cd->files.front()->get());
cd->files.erase(cd->files.front());
@@ -295,16 +296,16 @@ void EditorFileServer::_thread_start(void *s) {
}
}
- self->wait_mutex->lock();
+ self->wait_mutex.lock();
while (self->to_wait.size()) {
Thread *w = self->to_wait.front()->get();
self->to_wait.erase(w);
- self->wait_mutex->unlock();
+ self->wait_mutex.unlock();
Thread::wait_to_finish(w);
memdelete(w);
- self->wait_mutex->lock();
+ self->wait_mutex.lock();
}
- self->wait_mutex->unlock();
+ self->wait_mutex.unlock();
OS::get_singleton()->delay_usec(100000);
}
@@ -331,7 +332,6 @@ void EditorFileServer::stop() {
EditorFileServer::EditorFileServer() {
server.instance();
- wait_mutex = Mutex::create();
quit = false;
active = false;
cmd = CMD_NONE;
@@ -346,5 +346,4 @@ EditorFileServer::~EditorFileServer() {
quit = true;
Thread::wait_to_finish(thread);
memdelete(thread);
- memdelete(wait_mutex);
}
diff --git a/editor/fileserver/editor_file_server.h b/editor/fileserver/editor_file_server.h
index 4ce4c0cda6..cc3cb44566 100644
--- a/editor/fileserver/editor_file_server.h
+++ b/editor/fileserver/editor_file_server.h
@@ -62,7 +62,7 @@ class EditorFileServer : public Object {
static void _close_client(ClientData *cd);
static void _subthread_start(void *s);
- Mutex *wait_mutex;
+ Mutex wait_mutex;
Thread *thread;
static void _thread_start(void *);
bool quit;