summaryrefslogtreecommitdiff
path: root/platform/android/export
diff options
context:
space:
mode:
authorIbrahn Sahir <ibrahn.sahir@gmail.com>2018-07-13 13:30:50 +0100
committerIbrahn Sahir <ibrahn.sahir@gmail.com>2018-07-13 13:30:50 +0100
commitfe4265ad463e8fdf9bd1f8677d5e697b6ee090e0 (patch)
tree4d739ed01bb6b75714b45b52d9b50aa54e2d009a /platform/android/export
parent1fc7973a00e17025441b6b8333e38d1606c1d304 (diff)
fixed branch on uninit and data race in editor android device polling
Initialised relevant variables before stating thread, to prevent a branch on uninitialised data. Fixed race condition in polling that could miss a device change.
Diffstat (limited to 'platform/android/export')
-rw-r--r--platform/android/export/export.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index c3ff157f99..c562a47b00 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -228,7 +228,7 @@ class EditorExportAndroid : public EditorExportPlatform {
};
Vector<Device> devices;
- bool devices_changed;
+ volatile bool devices_changed;
Mutex *device_lock;
Thread *device_thread;
volatile bool quit_request;
@@ -1154,7 +1154,10 @@ public:
virtual bool poll_devices() {
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;
}
@@ -1857,9 +1860,9 @@ public:
run_icon->create_from_image(img);
device_lock = Mutex::create();
- device_thread = Thread::create(_device_poll_thread, this);
devices_changed = true;
quit_request = false;
+ device_thread = Thread::create(_device_poll_thread, this);
}
~EditorExportAndroid() {