Merge pull request #20132 from ibrahn/fix-android-device-poll-thread

fixed branch on uninit and data race in editor android device polling
This commit is contained in:
Rémi Verschelde 2018-07-17 14:48:49 +02:00 committed by GitHub
commit 26d3e31e05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -228,7 +228,7 @@ class EditorExportAndroid : public EditorExportPlatform {
}; };
Vector<Device> devices; Vector<Device> devices;
bool devices_changed; volatile bool devices_changed;
Mutex *device_lock; Mutex *device_lock;
Thread *device_thread; Thread *device_thread;
volatile bool quit_request; volatile bool quit_request;
@ -1154,7 +1154,10 @@ public:
virtual bool poll_devices() { virtual bool poll_devices() {
bool dc = devices_changed; bool dc = devices_changed;
devices_changed = false; if (dc) {
// don't clear unless we're reporting true, to avoid race
devices_changed = false;
}
return dc; return dc;
} }
@ -1857,9 +1860,9 @@ public:
run_icon->create_from_image(img); run_icon->create_from_image(img);
device_lock = Mutex::create(); device_lock = Mutex::create();
device_thread = Thread::create(_device_poll_thread, this);
devices_changed = true; devices_changed = true;
quit_request = false; quit_request = false;
device_thread = Thread::create(_device_poll_thread, this);
} }
~EditorExportAndroid() { ~EditorExportAndroid() {