Skip to content

Commit b235771

Browse files
authored
Fix GTK critical error causing freeze when changing Bible books (#1272)
Fixed a critical bug where Xiphos would freeze when attempting to change Bible books, throwing the GTK error: "gtk_box_pack: assertion '_gtk_widget_get_parent (child) == NULL' failed" Root cause: The parallel_vbox widget was being packed into widgets.page twice - once during creation in _create_parallel_tab() and again by the caller in tabbed_browser.c during session restore. GTK does not allow a widget to be added to a container when it already has a parent. Remove the automatic packing of parallel_vbox into widgets.page from _create_parallel_tab(). The function now only creates and returns the widget, following GTK best practices of separating widget creation from placement. Uncomment a gtk_box_pack_start() call to ensure the parallel tab widget is properly packed when opening a parallel view in a new tab. The widget is now packed exactly once by the caller, preventing the "widget already has a parent" error and eliminating the freeze.
1 parent 5dd72ea commit b235771

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/gtk/parallel_tab.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ GtkWidget *_create_parallel_tab(void)
227227
g_signal_connect(G_OBJECT(parallel_vbox), "destroy",
228228
G_CALLBACK(on_parallel_tab_destroy), NULL);
229229
gtk_widget_show(parallel_vbox);
230-
gtk_box_pack_start(GTK_BOX(widgets.page), parallel_vbox, TRUE,
231-
TRUE, 0);
230+
/* Don't pack into widgets.page here - let the caller manage placement
231+
* to avoid "widget already has a parent" GTK errors when switching tabs */
232232
toolbar29 = create_nav_toolbar();
233233
gtk_widget_show(toolbar29);
234234
gtk_box_pack_start(GTK_BOX(parallel_vbox), toolbar29, FALSE, FALSE,

src/gtk/tabbed_browser.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,8 +1467,8 @@ void gui_open_parallel_view_in_new_tab(void)
14671467
notebook_main_add_page(pt);
14681468
pt->paratab = gui_create_parallel_tab();
14691469
gui_parallel_tab_sync((gchar *)settings.currentverse);
1470-
/*gtk_box_pack_start(GTK_BOX(widgets.page), pt->paratab, TRUE, TRUE,
1471-
0); */
1470+
gtk_box_pack_start(GTK_BOX(widgets.page), pt->paratab, TRUE, TRUE,
1471+
0);
14721472
gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets.notebook_main),
14731473
gtk_notebook_page_num(GTK_NOTEBOOK(widgets.notebook_main),
14741474
pt->page_widget));

0 commit comments

Comments
 (0)