aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-02-07 02:33:11 +0100
committerdec05eba <dec05eba@protonmail.com>2022-02-07 02:33:11 +0100
commit9539a71dbeafdc4107d3b92eefada332ee45579a (patch)
tree65b8ceb183ee939f9684a783a40fc0f8fe5fd860 /src
parent9f12d8a7f6e4cdf0cb95130b69da2b368cc9cbb5 (diff)
Manga: fix crashes when navigating from/to creators page/bookmarks page (shared ptr deinit in non-main thread deiniting gl resources in non main thread), add pgup/pgdown/home/end to navigate manga faster
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp27
-rw-r--r--src/plugins/MangaCombined.cpp4
-rw-r--r--src/plugins/MangaGeneric.cpp5
-rw-r--r--src/plugins/Mangadex.cpp5
-rw-r--r--src/plugins/Page.cpp6
-rw-r--r--src/plugins/Soundcloud.cpp4
6 files changed, 44 insertions, 7 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index a5c423d..5a57022 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -205,7 +205,9 @@ namespace QuickMedia {
const char* get_title() const override { return "History"; }
PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override {
search_page->submit_body_item = submit_body_item;
- return search_page->submit(title, url, result_tabs);
+ PluginResult result = search_page->submit(title, url, result_tabs);
+ search_page->submit_body_item = nullptr;
+ return result;
}
PluginResult lazy_fetch(BodyItems &result_items) override {
switch(history_type) {
@@ -3658,6 +3660,26 @@ namespace QuickMedia {
page_navigation = 1;
goto end_of_images_page;
}
+ } else if(event.key.code == mgl::Keyboard::PageUp) {
+ if(image_index > 0) {
+ image_index = std::max(0, image_index - 10);
+ goto end_of_images_page;
+ }
+ } else if(event.key.code == mgl::Keyboard::PageDown) {
+ if(image_index < num_manga_pages) {
+ image_index = std::min(num_manga_pages, image_index + 10);
+ goto end_of_images_page;
+ }
+ } else if(event.key.code == mgl::Keyboard::Home) {
+ if(image_index > 0) {
+ image_index = 0;
+ goto end_of_images_page;
+ }
+ } else if(event.key.code == mgl::Keyboard::End) {
+ if(image_index < num_manga_pages) {
+ image_index = num_manga_pages;
+ goto end_of_images_page;
+ }
} else if(event.key.code == mgl::Keyboard::Escape) {
current_page = pop_page_stack();
} else if(event.key.code == mgl::Keyboard::I) {
@@ -7423,12 +7445,13 @@ namespace QuickMedia {
if(window.is_key_pressed(mgl::Keyboard::LControl) || window.is_key_pressed(mgl::Keyboard::RControl))
return;
- BodyItem *selected = file_manager_body->get_selected();
+ auto selected = file_manager_body->get_selected_shared();
if(!selected)
return;
std::vector<Tab> new_tabs;
TaskResult task_result = run_task_with_loading_screen([selected, &file_manager_page, &new_tabs]() {
+ file_manager_page->submit_body_item = selected;
return file_manager_page->submit(selected->get_title(), selected->url, new_tabs) == PluginResult::OK;
});
diff --git a/src/plugins/MangaCombined.cpp b/src/plugins/MangaCombined.cpp
index f678e57..06ecfc0 100644
--- a/src/plugins/MangaCombined.cpp
+++ b/src/plugins/MangaCombined.cpp
@@ -123,7 +123,9 @@ namespace QuickMedia {
Page *page = (Page*)submit_body_item->userdata;
if(!page) return PluginResult::OK;
page->submit_body_item = submit_body_item;
- return page->submit(title, url, result_tabs);
+ PluginResult result = page->submit(title, url, result_tabs);
+ page->submit_body_item = nullptr;
+ return result;
}
void MangaCombinedSearchPage::cancel_operation() {
diff --git a/src/plugins/MangaGeneric.cpp b/src/plugins/MangaGeneric.cpp
index 0c1ee37..e8d8992 100644
--- a/src/plugins/MangaGeneric.cpp
+++ b/src/plugins/MangaGeneric.cpp
@@ -406,7 +406,10 @@ namespace QuickMedia {
}
PluginResult MangaGenericCreatorPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- return search_page->submit(title, url, result_tabs);
+ search_page->submit_body_item = submit_body_item;
+ PluginResult result = search_page->submit(title, url, result_tabs);
+ search_page->submit_body_item = nullptr;
+ return result;
}
PluginResult MangaGenericCreatorPage::lazy_fetch(BodyItems &result_items) {
diff --git a/src/plugins/Mangadex.cpp b/src/plugins/Mangadex.cpp
index 88f4c18..79341bd 100644
--- a/src/plugins/Mangadex.cpp
+++ b/src/plugins/Mangadex.cpp
@@ -386,7 +386,10 @@ namespace QuickMedia {
}
PluginResult MangadexCreatorPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- return search_page->submit(title, url, result_tabs);
+ search_page->submit_body_item = submit_body_item;
+ PluginResult result = search_page->submit(title, url, result_tabs);
+ search_page->submit_body_item = nullptr;
+ return result;
}
PluginResult MangadexCreatorPage::get_page(const std::string&, int page, BodyItems &result_items) {
diff --git a/src/plugins/Page.cpp b/src/plugins/Page.cpp
index 2e3caf4..c7b0bb3 100644
--- a/src/plugins/Page.cpp
+++ b/src/plugins/Page.cpp
@@ -72,7 +72,11 @@ namespace QuickMedia {
}
PluginResult BookmarksPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- return redirect_page->submit(title, url, result_tabs);
+ // TODO: Find a better solution to not keep the submit body item alive
+ redirect_page->submit_body_item = submit_body_item;
+ PluginResult result = redirect_page->submit(title, url, result_tabs);
+ redirect_page->submit_body_item = nullptr;
+ return result;
}
PluginResult BookmarksPage::lazy_fetch(BodyItems &result_items) {
diff --git a/src/plugins/Soundcloud.cpp b/src/plugins/Soundcloud.cpp
index fa37e29..7f2b1f1 100644
--- a/src/plugins/Soundcloud.cpp
+++ b/src/plugins/Soundcloud.cpp
@@ -288,7 +288,9 @@ namespace QuickMedia {
PluginResult SoundcloudSearchPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
submit_page.submit_body_item = submit_body_item;
- return submit_page.submit(title, url, result_tabs);
+ PluginResult result = submit_page.submit(title, url, result_tabs);
+ submit_page.submit_body_item = nullptr;
+ return result;
}
SearchResult SoundcloudSearchPage::search(const std::string &str, BodyItems &result_items) {