aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-05-26 14:50:58 +0200
committerdec05eba <dec05eba@protonmail.com>2021-05-26 14:51:05 +0200
commit9f95dcdb78b7675a5ef97eb0d354f4be86f9d6be (patch)
tree2c51d392b93c8ee23789cad89697c8de077d4617 /src/QuickMedia.cpp
parent481ea1234a7d53061350af46e8fffd86fde46dc6 (diff)
Fix room avatar getting corrupt after returning from watching media
Also dont save file manager path to disk. Save it to ram only
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index e93536b..873bd31 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -319,7 +319,7 @@ namespace QuickMedia {
fprintf(stderr, " --use-system-mpv-config Use system mpv config instead of no config. Disabled by default\n");
fprintf(stderr, " --upscale-images Upscale low-resolution manga pages using waifu2x-ncnn-vulkan. Disabled by default\n");
fprintf(stderr, " --upscale-images-always Upscale manga pages using waifu2x-ncnn-vulkan, no matter what the original image resolution is. Disabled by default\n");
- fprintf(stderr, " --dir <directory> Set the start directory when using file-manager. Default is the last accessed directory in QuickMedia or the users home directory\n");
+ fprintf(stderr, " --dir <directory> Set the start directory when using file-manager. Default is the the users home directory\n");
fprintf(stderr, " -e <window> Embed QuickMedia into another window\n");
fprintf(stderr, "EXAMPLES:\n");
fprintf(stderr, " quickmedia launcher\n");
@@ -4861,8 +4861,10 @@ namespace QuickMedia {
const float logo_padding_x = std::floor(15.0f * get_ui_scale());
const float chat_input_padding_x = std::floor(10.0f * get_ui_scale());
const float chat_input_padding_y = std::floor(10.0f * get_ui_scale());
+
+ bool avatar_applied = false;
- auto launch_url = [this, matrix_chat_page, &video_page, &redraw](const std::string &url) mutable {
+ auto launch_url = [this, matrix_chat_page, &video_page, &redraw, &avatar_applied](const std::string &url) mutable {
if(url.empty())
return;
@@ -4876,6 +4878,7 @@ namespace QuickMedia {
// TODO: Add title
video_content_page(matrix_chat_page, video_page.get(), "", false, next_items, 0);
redraw = true;
+ avatar_applied = false;
} else {
const char *launch_program = "xdg-open";
if(!is_program_executable_by_name("xdg-open")) {
@@ -4933,7 +4936,7 @@ namespace QuickMedia {
}
};
- auto display_url_or_image = [this, matrix_chat_page, &ui_tabs, &redraw, &video_page, &launch_url, &chat_state, &url_selection_body, PINNED_TAB_INDEX, MESSAGES_TAB_INDEX](BodyItem *selected) {
+ auto display_url_or_image = [this, matrix_chat_page, &ui_tabs, &redraw, &video_page, &launch_url, &chat_state, &url_selection_body, &avatar_applied, PINNED_TAB_INDEX, MESSAGES_TAB_INDEX](BodyItem *selected) {
if(!selected)
return false;
@@ -4961,6 +4964,7 @@ namespace QuickMedia {
video_content_page(matrix_chat_page, video_page.get(), "", message_type == MessageType::VIDEO || message_type == MessageType::AUDIO, next_items, 0);
no_video = prev_no_video;
redraw = true;
+ avatar_applied = false;
return true;
} else if(message_type == MessageType::FILE) {
download_async_gui(selected->url, FileManagerPage::get_last_accessed_directory(file_manager_start_dir).string(), false, no_video);
@@ -5496,9 +5500,11 @@ namespace QuickMedia {
//room_avatar_thumbnail_data->texture.generateMipmap();
room_avatar_thumbnail_data->image.reset();
room_avatar_thumbnail_data->loading_state = LoadingState::APPLIED_TO_TEXTURE;
+ avatar_applied = false;
}
- if(room_avatar_thumbnail_data->loading_state == LoadingState::APPLIED_TO_TEXTURE && !room_avatar_sprite.getTexture()) {
+ if(room_avatar_thumbnail_data->loading_state == LoadingState::APPLIED_TO_TEXTURE && !avatar_applied) {
+ avatar_applied = true;
room_avatar_sprite.setTexture(room_avatar_thumbnail_data->texture, true);
auto texture_size = room_avatar_sprite.getTexture()->getSize();
if(texture_size.x > 0 && texture_size.y > 0) {
@@ -5671,7 +5677,7 @@ namespace QuickMedia {
if(selected_tab == MESSAGES_TAB_INDEX || selected_tab == PINNED_TAB_INDEX || selected_tab == USERS_TAB_INDEX) {
float room_name_text_offset_x = 0.0f;
- if(room_avatar_sprite.getTexture() && room_avatar_sprite.getTexture()->getNativeHandle() != 0) {
+ if(room_avatar_thumbnail_data->loading_state == LoadingState::APPLIED_TO_TEXTURE && room_avatar_sprite.getTexture() && room_avatar_sprite.getTexture()->getNativeHandle() != 0) {
auto room_avatar_texture_size = room_avatar_sprite.getTexture()->getSize();
room_avatar_texture_size.x *= room_avatar_sprite.getScale().x;
room_avatar_texture_size.y *= room_avatar_sprite.getScale().y;