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.
(cherry picked from commit fe4265ad46
)
This commit is contained in:
parent
4b69ed4124
commit
b890ed527b
|
@ -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;
|
||||
|
@ -1156,7 +1156,10 @@ public:
|
|||
virtual bool poll_devices() {
|
||||
|
||||
bool dc = devices_changed;
|
||||
if (dc) {
|
||||
// don't clear unless we're reporting true, to avoid race
|
||||
devices_changed = false;
|
||||
}
|
||||
return dc;
|
||||
}
|
||||
|
||||
|
@ -1859,9 +1862,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() {
|
||||
|
|
Loading…
Reference in New Issue