diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-09-24 02:01:54 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-09-24 02:06:43 +0200 |
commit | fe6db40c2f6cd10b4af086d622cf59442b7e7c67 (patch) | |
tree | 71b73ef9ce282fa267024144739f596203baf3ce /src | |
parent | e5d323cb063cd5762a6945439028c1ee7756aa45 (diff) |
Fix segfault on file manager exit, unload thumbnails on tab switch
Diffstat (limited to 'src')
-rw-r--r-- | src/Body.cpp | 4 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/Body.cpp b/src/Body.cpp index 39f6e01..c53a476 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -271,7 +271,7 @@ namespace QuickMedia { Path thumbnail_path = get_cache_dir().join("thumbnails").join(base64_url::encode(url)); std::string texture_data; - if(thumbnail_resize_target_size.x != 0 && thumbnail_resize_target_size.y != 0 && file_get_content(thumbnail_path, texture_data) == 0) { + if(file_get_content(thumbnail_path, texture_data) == 0) { fprintf(stderr, "Loaded %s from thumbnail cache\n", url.c_str()); result->loadFromMemory(texture_data.data(), texture_data.size()); loading_thumbnail = false; @@ -443,7 +443,7 @@ namespace QuickMedia { glScissor(scissor_pos.x, (int)window_size.y - (int)scissor_pos.y - (int)scissor_size.y, scissor_size.x, scissor_size.y); for(int i = first_visible_item + 1; i < num_items; ++i) { - const auto &item = items[i]; + auto &item = items[i]; if(pos.y >= start_y + size.y) break; diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 09c6e01..5d8a7e4 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -252,7 +252,7 @@ namespace QuickMedia { delete body; if(file_manager) delete file_manager; - if(current_plugin) + if(current_plugin && current_plugin != file_manager) delete current_plugin; if(disp) XCloseDisplay(disp); @@ -1097,6 +1097,7 @@ namespace QuickMedia { if(tabs[selected_tab].body) { tabs[selected_tab].body->filter_search_fuzzy(""); tabs[selected_tab].body->clamp_selection(); + tabs[selected_tab].body->clear_thumbnails(); } selected_tab = std::max(0, selected_tab - 1); search_bar->clear(); @@ -1104,6 +1105,7 @@ namespace QuickMedia { if(tabs[selected_tab].body) { tabs[selected_tab].body->filter_search_fuzzy(""); tabs[selected_tab].body->clamp_selection(); + tabs[selected_tab].body->clear_thumbnails(); } selected_tab = std::min((int)tabs.size() - 1, selected_tab + 1); search_bar->clear(); @@ -1869,11 +1871,13 @@ namespace QuickMedia { } else if(event.key.code == sf::Keyboard::Left) { tabs[selected_tab].body->filter_search_fuzzy(""); tabs[selected_tab].body->clamp_selection(); + tabs[selected_tab].body->clear_thumbnails(); selected_tab = std::max(0, selected_tab - 1); search_bar->clear(); } else if(event.key.code == sf::Keyboard::Right) { tabs[selected_tab].body->filter_search_fuzzy(""); tabs[selected_tab].body->clamp_selection(); + tabs[selected_tab].body->clear_thumbnails(); selected_tab = std::min((int)tabs.size() - 1, selected_tab + 1); search_bar->clear(); } @@ -2579,7 +2583,7 @@ namespace QuickMedia { search_bar->text_autosearch_delay = prev_autosearch_delay; // We want exit code 1 if the file manager was launched and no files were selected, to know when the user didn't select any file(s) if(selected_files.empty() && current_page == Page::EXIT) - exit(1); + exit_code = 1; } void Program::image_board_thread_list_page() { @@ -3333,11 +3337,13 @@ namespace QuickMedia { } else if(event.key.code == sf::Keyboard::Left) { tabs[selected_tab].body->filter_search_fuzzy(""); tabs[selected_tab].body->clamp_selection(); + tabs[selected_tab].body->clear_thumbnails(); selected_tab = std::max(0, selected_tab - 1); chat_input.clear(); } else if(event.key.code == sf::Keyboard::Right) { tabs[selected_tab].body->filter_search_fuzzy(""); tabs[selected_tab].body->clamp_selection(); + tabs[selected_tab].body->clear_thumbnails(); selected_tab = std::min((int)tabs.size() - 1, selected_tab + 1); chat_input.clear(); } |