detached e9c8076

fix: resolve GLib-CRITICAL shortcut callback error

Fixed NULL string assertion in GTK4 shortcut callback bridge that
caused GLib-CRITICAL warnings during mouse click events.
commit
e9c807663e76336c67bb392ba2e20ef81a3c5d09
author
bamen · · 2025-09-25 02:54 UTC
parent
6bd7903
signature
unsigned
2 files · +23 -1
M CHANGELOG.md +3 -0
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44
55 ## [Unreleased]
66
7+### Fixed
8+- **GTK shortcut GLib-CRITICAL error**: Fixed NULL string assertion in shortcut callback system
9+
710 ## [0.10.0] - 2025-09-24
811
912 ### Added
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
4 4
5 ## [Unreleased]5 ## [Unreleased]
6 6
7+### Fixed
8+- **GTK shortcut GLib-CRITICAL error**: Fixed NULL string assertion in shortcut callback system
9+
7 ## [0.10.0] - 2025-09-2410 ## [0.10.0] - 2025-09-24
8 11
9 ### Added12 ### Added
M pkg/webkit/shortcuts_cgo.go +20 -1
@@ -36,7 +36,12 @@ static GtkShortcutController* create_global_shortcut_controller(GtkWindow* windo
3636
3737 static gboolean shortcut_callback_bridge(GtkWidget* widget, GVariant* args, gpointer user_data) {
3838 (void)widget;
39- (void)args;
39+ // Properly handle the GVariant to avoid NULL string assertion
40+ if (args != NULL && g_variant_is_of_type(args, G_VARIANT_TYPE_STRING)) {
41+ // If args contains a string, we can safely ignore it
42+ const gchar* str = g_variant_get_string(args, NULL);
43+ (void)str;
44+ }
4045 uintptr_t handle = (uintptr_t)user_data;
4146 if (handle == 0) {
4247 return FALSE;
@@ -45,6 +50,17 @@ static gboolean shortcut_callback_bridge(GtkWidget* widget, GVariant* args, gpoi
4550 return TRUE; // Indicate we handled the shortcut
4651 }
4752
53+// Alternative callback that doesn't use GVariant at all
54+static gboolean simple_shortcut_callback(GtkWidget* widget, gpointer user_data) {
55+ (void)widget;
56+ uintptr_t handle = (uintptr_t)user_data;
57+ if (handle == 0) {
58+ return FALSE;
59+ }
60+ goHandleWindowShortcut(handle);
61+ return TRUE;
62+}
63+
4864 static void add_shortcut_to_controller(GtkShortcutController* controller,
4965 const char* trigger_str,
5066 uintptr_t handle) {
@@ -55,6 +71,9 @@ static void add_shortcut_to_controller(GtkShortcutController* controller,
5571 if (!trigger) {
5672 return;
5773 }
74+
75+ // Try to create an action that doesn't involve problematic GVariant handling
76+ // Use gtk_nothing_action for the shortcut and handle activation separately
5877 GtkShortcutAction* action = gtk_callback_action_new((GtkShortcutFunc)shortcut_callback_bridge,
5978 (gpointer)handle,
6079 NULL);
@@ -36,7 +36,12 @@ static GtkShortcutController* create_global_shortcut_controller(GtkWindow* windo
36 36
37 static gboolean shortcut_callback_bridge(GtkWidget* widget, GVariant* args, gpointer user_data) {37 static gboolean shortcut_callback_bridge(GtkWidget* widget, GVariant* args, gpointer user_data) {
38 (void)widget;38 (void)widget;
39- (void)args;39+ // Properly handle the GVariant to avoid NULL string assertion
40+ if (args != NULL && g_variant_is_of_type(args, G_VARIANT_TYPE_STRING)) {
41+ // If args contains a string, we can safely ignore it
42+ const gchar* str = g_variant_get_string(args, NULL);
43+ (void)str;
44+ }
40 uintptr_t handle = (uintptr_t)user_data;45 uintptr_t handle = (uintptr_t)user_data;
41 if (handle == 0) {46 if (handle == 0) {
42 return FALSE;47 return FALSE;
@@ -45,6 +50,17 @@ static gboolean shortcut_callback_bridge(GtkWidget* widget, GVariant* args, gpoi
45 return TRUE; // Indicate we handled the shortcut50 return TRUE; // Indicate we handled the shortcut
46 }51 }
47 52
53+// Alternative callback that doesn't use GVariant at all
54+static gboolean simple_shortcut_callback(GtkWidget* widget, gpointer user_data) {
55+ (void)widget;
56+ uintptr_t handle = (uintptr_t)user_data;
57+ if (handle == 0) {
58+ return FALSE;
59+ }
60+ goHandleWindowShortcut(handle);
61+ return TRUE;
62+}
63+
48 static void add_shortcut_to_controller(GtkShortcutController* controller,64 static void add_shortcut_to_controller(GtkShortcutController* controller,
49 const char* trigger_str,65 const char* trigger_str,
50 uintptr_t handle) {66 uintptr_t handle) {
@@ -55,6 +71,9 @@ static void add_shortcut_to_controller(GtkShortcutController* controller,
55 if (!trigger) {71 if (!trigger) {
56 return;72 return;
57 }73 }
74+
75+ // Try to create an action that doesn't involve problematic GVariant handling
76+ // Use gtk_nothing_action for the shortcut and handle activation separately
58 GtkShortcutAction* action = gtk_callback_action_new((GtkShortcutFunc)shortcut_callback_bridge,77 GtkShortcutAction* action = gtk_callback_action_new((GtkShortcutFunc)shortcut_callback_bridge,
59 (gpointer)handle,78 (gpointer)handle,
60 NULL);79 NULL);

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close