Modifying SDL initialization due to crash on OSX

This commit is contained in:
Bradley Austin Davis 2017-09-08 11:36:32 -07:00 committed by Chris Collins
parent 0f465da92f
commit 45a2c3d5d9

View file

@ -54,6 +54,25 @@ SDL_JoystickID SDL2Manager::getInstanceId(SDL_GameController* controller) {
}
void SDL2Manager::init() {
}
QStringList SDL2Manager::getSubdeviceNames() {
return _subdeviceNames;
}
void SDL2Manager::deinit() {
_openJoysticks.clear();
SDL_Quit();
}
bool SDL2Manager::activate() {
// FIXME for some reason calling this code in the `init` function triggers a crash
// on OSX in PR builds, but not on my local debug build. Attempting a workaround by
//
static std::once_flag once;
std::call_once(once, [&]{
loadSettings();
auto preferences = DependencyManager::get<Preferences>();
@ -93,25 +112,16 @@ void SDL2Manager::init() {
}
_isInitialized = true;
}
else {
} else {
qDebug() << "Error initializing SDL2 Manager";
}
});
if (!_isInitialized) {
return false;
}
QStringList SDL2Manager::getSubdeviceNames() {
return _subdeviceNames;
}
void SDL2Manager::deinit() {
_openJoysticks.clear();
SDL_Quit();
}
bool SDL2Manager::activate() {
InputPlugin::activate();
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
for (auto joystick : _openJoysticks) {
userInputMapper->registerDevice(joystick);