From 7e215ee0695616c09cb902d1a018db71a1ea868b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 24 May 2015 02:55:16 +0200 Subject: [PATCH] Ensure that Unix wxJoystick closes the associated device. Close the device file descriptor in the dtor instead of doing it in the thread used to poll it, this is more straightforward and ensures that it happens even if the thread failed to run for whatever reason. --- src/unix/joystick.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/joystick.cpp b/src/unix/joystick.cpp index 5896e0450f..928e9f6fc9 100644 --- a/src/unix/joystick.cpp +++ b/src/unix/joystick.cpp @@ -192,7 +192,6 @@ void* wxJoystickThread::Entry() } } - close(m_device); return NULL; } @@ -231,7 +230,8 @@ wxJoystick::~wxJoystick() ReleaseCapture(); if (m_thread) m_thread->Delete(); // It's detached so it will delete itself - m_device = -1; + if (m_device != -1) + close(m_device); }