Break out of the loop waiting for the SearchBT to be done in WiimoteScannerDarwin::FindWiimotes() when the object is destroyed. Allows the application to quit correctly when Continuous Scanning is enabled on macOS.

This commit is contained in:
Andrew Molloy 2017-12-03 11:41:06 -05:00
parent d306397bbc
commit 8354e89cf1
2 changed files with 9 additions and 2 deletions

View file

@ -13,10 +13,12 @@ class WiimoteScannerDarwin final : public WiimoteScannerBackend
{
public:
WiimoteScannerDarwin() = default;
~WiimoteScannerDarwin() override = default;
~WiimoteScannerDarwin() override;
bool IsReady() const override;
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override;
void Update() override {} // not needed
private:
bool stopScanning = false;
};
}

View file

@ -21,6 +21,11 @@
namespace WiimoteReal
{
WiimoteScannerDarwin::~WiimoteScannerDarwin()
{
stopScanning = true;
}
void WiimoteScannerDarwin::FindWiimotes(std::vector<Wiimote*>& found_wiimotes,
Wiimote*& found_board)
{
@ -55,7 +60,7 @@ void WiimoteScannerDarwin::FindWiimotes(std::vector<Wiimote*>& found_wiimotes,
do
{
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
} while (!sbt->done);
} while (!sbt->done && !stopScanning);
int found_devices = [[bti foundDevices] count];