aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AsyncImageLoader.cpp7
-rw-r--r--src/Body.cpp3
-rw-r--r--src/QuickMedia.cpp3
3 files changed, 10 insertions, 3 deletions
diff --git a/src/AsyncImageLoader.cpp b/src/AsyncImageLoader.cpp
index 136bd5b..d0a67c4 100644
--- a/src/AsyncImageLoader.cpp
+++ b/src/AsyncImageLoader.cpp
@@ -94,6 +94,13 @@ namespace QuickMedia {
}
}
+ AsyncImageLoader& AsyncImageLoader::get_instance() {
+ static AsyncImageLoader *instance = nullptr;
+ if(!instance)
+ instance = new AsyncImageLoader();
+ return *instance;
+ }
+
AsyncImageLoader::AsyncImageLoader() {
for(int i = 0; i < NUM_IMAGE_LOAD_THREADS; ++i) {
loading_image[i] = false;
diff --git a/src/Body.cpp b/src/Body.cpp
index 04330b8..0143fe2 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -2,6 +2,7 @@
#include "../include/QuickMedia.hpp"
#include "../include/Scale.hpp"
#include "../include/ResourceLoader.hpp"
+#include "../include/AsyncImageLoader.hpp"
#include "../plugins/Plugin.hpp"
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/OpenGL.hpp>
@@ -899,7 +900,7 @@ namespace QuickMedia {
item_thumbnail->referenced = true;
if(!item->thumbnail_url.empty() && item_thumbnail->loading_state == LoadingState::NOT_LOADED)
- async_image_loader.load_thumbnail(item->thumbnail_url, item->thumbnail_is_local, content_size, program->is_tor_enabled(), item_thumbnail);
+ AsyncImageLoader::get_instance().load_thumbnail(item->thumbnail_url, item->thumbnail_is_local, content_size, program->is_tor_enabled(), item_thumbnail);
if(item_thumbnail->loading_state == LoadingState::FINISHED_LOADING && item_thumbnail->image->getSize().x > 0 && item_thumbnail->image->getSize().y > 0) {
if(!item_thumbnail->texture.loadFromImage(*item_thumbnail->image))
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index f93dde9..866d27d 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3171,7 +3171,6 @@ namespace QuickMedia {
sf::Sprite room_avatar_sprite;
auto room_avatar_thumbnail_data = std::make_shared<ThumbnailData>();
- AsyncImageLoader async_image_loader;
sf::Clock read_marker_timer;
const sf::Int32 read_marker_timeout_ms_default = 3000;
@@ -4351,7 +4350,7 @@ namespace QuickMedia {
}
if(current_room && current_room->userdata && room_avatar_thumbnail_data->loading_state == LoadingState::NOT_LOADED)
- async_image_loader.load_thumbnail(static_cast<BodyItem*>(current_room->userdata)->thumbnail_url, false, sf::Vector2i(32, 32), use_tor, room_avatar_thumbnail_data);
+ AsyncImageLoader::get_instance().load_thumbnail(static_cast<BodyItem*>(current_room->userdata)->thumbnail_url, false, sf::Vector2i(32, 32), use_tor, room_avatar_thumbnail_data);
if(room_avatar_thumbnail_data->loading_state == LoadingState::FINISHED_LOADING && room_avatar_thumbnail_data->image->getSize().x > 0 && room_avatar_thumbnail_data->image->getSize().y > 0) {
if(!room_avatar_thumbnail_data->texture.loadFromImage(*room_avatar_thumbnail_data->image))