From 0f0bf1c649388c07ae6e8dd784d7402f68691b96 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 8 Jun 2021 13:39:11 +0200 Subject: Remove images that are not visible from the loading queue, prepare for inline images --- src/AsyncImageLoader.cpp | 3 +++ src/Body.cpp | 8 ++++---- src/Entry.cpp | 8 ++++---- src/Text.cpp | 8 ++++---- 4 files changed, 15 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/AsyncImageLoader.cpp b/src/AsyncImageLoader.cpp index 1769846..1a1e120 100644 --- a/src/AsyncImageLoader.cpp +++ b/src/AsyncImageLoader.cpp @@ -227,6 +227,9 @@ namespace QuickMedia { bool loaded_textures_changed = false; for(auto it = thumbnails.begin(); it != thumbnails.end();) { if(it->second->counter != counter) { + image_load_queue.erase_if([&it](ThumbnailLoadData &load_data) { + return load_data.path.data == it->first; + }); it = thumbnails.erase(it); loaded_textures_changed = true; } else { diff --git a/src/Body.cpp b/src/Body.cpp index 3df816c..d84785a 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -701,8 +701,8 @@ namespace QuickMedia { } bool instant_move = body_size_changed; - if(target_y_set == TargetSetState::SET) { - target_y_set = TargetSetState::APPLIED; + if(target_set == TargetSetState::SET) { + target_set = TargetSetState::APPLIED; instant_move = true; } @@ -941,8 +941,8 @@ namespace QuickMedia { if(item_index == selected_item) { item_background_target_pos = pos; item_background_target_size = sf::Vector2f(item_width, item_height); - if(target_y_set == TargetSetState::NOT_SET) - target_y_set = TargetSetState::SET; + if(target_set == TargetSetState::NOT_SET) + target_set = TargetSetState::SET; } } diff --git a/src/Entry.cpp b/src/Entry.cpp index 7e1b6d9..8e1fbfb 100644 --- a/src/Entry.cpp +++ b/src/Entry.cpp @@ -82,8 +82,8 @@ namespace QuickMedia { text.setEditable(editable); } - void Entry::set_text(std::string new_text) { - text.setString(sf::String::fromUtf8(new_text.data(), new_text.data() + new_text.size())); + void Entry::set_text(const std::string &new_text) { + text.setString(sf::String::fromUtf8(new_text.begin(), new_text.end())); } void Entry::move_caret_to_end() { @@ -91,8 +91,8 @@ namespace QuickMedia { text.moveCaretToEnd(); } - void Entry::append_text(std::string str) { - text.appendText(std::move(str)); + void Entry::append_text(const std::string &str) { + text.appendText(sf::String::fromUtf8(str.begin(), str.end())); } void Entry::replace(size_t start_index, size_t length, const sf::String &insert_str) { diff --git a/src/Text.cpp b/src/Text.cpp index 2e735ab..7859c7a 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -55,12 +55,12 @@ namespace QuickMedia setString(std::move(_str)); } - void Text::setString(sf::String str) + void Text::setString(const sf::String &str) { //if(str != this->str) //{ size_t prev_str_size = this->str.getSize(); - this->str = std::move(str); + this->str = str; dirty = true; dirtyText = true; if((int)this->str.getSize() < caretIndex || prev_str_size == 0) @@ -76,8 +76,8 @@ namespace QuickMedia return str; } - void Text::appendText(sf::String str) { - this->str += std::move(str); + void Text::appendText(const sf::String &str) { + this->str += str; dirty = true; dirtyText = true; } -- cgit v1.2.3