Fix crash when opening settings page because of recent change

This commit is contained in:
dec05eba
2025-05-24 18:24:18 +02:00
parent b807712d79
commit b80e3f8beb
5 changed files with 18 additions and 9 deletions

View File

@@ -14,7 +14,7 @@ A program called `gsr-ui-cli` is also installed when installing this software. T
# Installation
If you are using an Arch Linux based distro then you can find gpu screen recorder ui on aur under the name gpu-screen-recorder-ui (`yay -S gpu-screen-recorder-ui`).\
If you are running another distro then you can run `sudo ./install.sh`, but you need to manually install the dependencies, as described below.\
You can also install gpu screen recorder from [flathub](https://flathub.org/apps/details/com.dec05eba.gpu_screen_recorder). This flatpak includes both this UI and gpu-screen-recorder so no need to install that first.
You can also install gpu screen recorder from [flathub](https://flathub.org/apps/details/com.dec05eba.gpu_screen_recorder) which includes this UI.
# Dependencies
GPU Screen Recorder UI uses meson build system so you need to install `meson` to build GPU Screen Recorder UI.

2
TODO
View File

@@ -37,8 +37,6 @@ Fix first frame being black when running without a compositor.
Add support for systray.
Add option to take screenshot.
Move event callbacks to a global list instead of std::function object in each widget. This reduces the size of widgets,
since most widgets wont have the event callback set.
This event callback would pass the widget as an argument.

View File

@@ -200,7 +200,6 @@ namespace gsr {
RadioButton *turn_on_replay_automatically_mode_ptr = nullptr;
Subsection *audio_section_ptr = nullptr;
List *audio_track_section_list_ptr = nullptr;
List *replay_storage_list_ptr = nullptr;
PageStack *page_stack = nullptr;
};

View File

@@ -37,6 +37,7 @@
#include <X11/Xcursor/Xcursor.h>
#include <mglpp/system/Rect.hpp>
#include <mglpp/window/Event.hpp>
#include <mglpp/system/Utf8.hpp>
extern "C" {
#include <mgl/mgl.h>
@@ -903,6 +904,7 @@ namespace gsr {
// Wayland doesn't allow XGrabPointer/XGrabKeyboard when a wayland application is focused.
// If the focused window is a wayland application then don't use override redirect and instead create
// a fullscreen window for the ui.
// TODO: (x11_cursor_window && is_window_fullscreen_on_monitor(display, x11_cursor_window, *focused_monitor))
const bool prevent_game_minimizing = gsr_info.system_info.display_server != DisplayServer::WAYLAND || x11_cursor_window || is_wlroots;
if(prevent_game_minimizing) {
@@ -1640,10 +1642,22 @@ namespace gsr {
return result;
}
// TODO: Utf8 truncate
static void truncate_string(std::string &str, int max_length) {
if((int)str.size() > max_length)
str.replace(str.begin() + max_length, str.end(), "...");
int index = 0;
size_t byte_index = 0;
while(index < max_length && byte_index < str.size()) {
uint32_t codepoint = 0;
size_t codepoint_length = 0;
mgl::utf8_decode((const unsigned char*)str.c_str() + byte_index, str.size() - byte_index, &codepoint, &codepoint_length);
if(codepoint_length == 0)
codepoint_length = 1;
index += 1;
byte_index += codepoint_length;
}
str.erase(byte_index);
}
void Overlay::save_video_in_current_game_directory(const char *video_filepath, NotificationType notification_type) {

View File

@@ -768,7 +768,6 @@ namespace gsr {
list->add_widget(std::move(replay_storage_button));
list->set_visible(gsr_info->system_info.gsr_version >= GsrVersion{5, 5, 0});
replay_storage_list_ptr = list.get();
return list;
}
@@ -837,7 +836,6 @@ namespace gsr {
notifications_subsection_ptr->set_visible(advanced_view);
set_application_audio_options_visible(audio_track_section_list_ptr, advanced_view, *gsr_info);
settings_scrollable_page_ptr->reset_scroll();
replay_storage_list_ptr->set_visible(advanced_view && gsr_info->system_info.gsr_version >= GsrVersion{5, 5, 0});
}
void SettingsPage::add_replay_widgets() {