summaryrefslogtreecommitdiff
path: root/src/gfxinit.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-03-08 14:50:06 +0100
committerPatric Stout <github@truebrain.nl>2021-03-08 19:18:55 +0100
commit8946b41d20d6be59da23b98add273955b43450fd (patch)
tree59efe6e340339a68f4355a0c19cda5695755e49c /src/gfxinit.cpp
parente56d2c63c306dd087de26088729d09233b1122c2 (diff)
downloadopenttd-8946b41d20d6be59da23b98add273955b43450fd.tar.xz
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.
Diffstat (limited to 'src/gfxinit.cpp')
-rw-r--r--src/gfxinit.cpp11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp
index 2883d3ee3..7e2c2cc62 100644
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -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;
}