From 0d8293a5647c2bb10228658f0910515b38ff0d64 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 21 Oct 2020 21:32:51 +0200 Subject: Workaround sfml image loading thread race condition See: https://github.com/SFML/SFML/issues/1711 Also some other smaller changes --- src/SfmlFixes.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/SfmlFixes.cpp (limited to 'src/SfmlFixes.cpp') diff --git a/src/SfmlFixes.cpp b/src/SfmlFixes.cpp new file mode 100644 index 0000000..d6d4b17 --- /dev/null +++ b/src/SfmlFixes.cpp @@ -0,0 +1,15 @@ +#include "../include/SfmlFixes.hpp" +#include + +static std::mutex mutex; +namespace QuickMedia { + bool load_image_from_file(sf::Image &image, const std::string &filepath) { + std::lock_guard lock(mutex); + return image.loadFromFile(filepath); + } + + bool load_image_from_memory(sf::Image &image, const void *data, size_t size) { + std::lock_guard lock(mutex); + return image.loadFromMemory(data, size); + } +} \ No newline at end of file -- cgit v1.2.3