mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-09-03 03:49:12 +00:00
Fix: ensure switching blitter happens in the main thread
This because video-drivers might need to make changes to their context, which for most video-drivers has to be done in the same thread as the window was created; main thread in our case.
This commit is contained in:
committed by
Patric Stout
parent
e56d2c63c3
commit
8946b41d20
@@ -308,18 +308,11 @@ static bool SwitchNewGRFBlitter()
|
||||
}
|
||||
if (BlitterFactory::GetBlitterFactory(repl_blitter) == nullptr) continue;
|
||||
|
||||
DEBUG(misc, 1, "Switching blitter from '%s' to '%s'... ", cur_blitter, repl_blitter);
|
||||
Blitter *new_blitter = BlitterFactory::SelectBlitter(repl_blitter);
|
||||
if (new_blitter == nullptr) NOT_REACHED();
|
||||
DEBUG(misc, 1, "Successfully switched to %s.", repl_blitter);
|
||||
/* Inform the video driver we want to switch blitter as soon as possible. */
|
||||
VideoDriver::GetInstance()->ChangeBlitter(repl_blitter);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!VideoDriver::GetInstance()->AfterBlitterChange()) {
|
||||
/* Failed to switch blitter, let's hope we can return to the old one. */
|
||||
if (BlitterFactory::SelectBlitter(cur_blitter) == nullptr || !VideoDriver::GetInstance()->AfterBlitterChange()) usererror("Failed to reinitialize video driver. Specify a fixed blitter in the config");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user