Skip to content

Commit

Permalink
Merge pull request #1221 from lwindolf/fix-1214
Browse files Browse the repository at this point in the history
Refactor htmlview/signals to avoid #1214 crashes
  • Loading branch information
lwindolf authored Mar 31, 2023
2 parents c0ab74b + adffcf1 commit 47e226c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 40 deletions.
21 changes: 10 additions & 11 deletions src/ui/itemview.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,17 +400,8 @@ itemview_set_layout (nodeViewType newMode)
itemlist_unload ();

/* Prepare widgets for layout */
if (!itemview->htmlview) {
debug0 (DEBUG_GUI, "Creating HTML widget");
itemview->htmlview = liferea_browser_new (FALSE);
g_signal_connect (itemview->htmlview, "statusbar-changed",
G_CALLBACK (on_important_status_message), NULL);

/* Set initial zoom */
liferea_browser_set_zoom (itemview->htmlview, itemview->zoom/100.);
} else {
liferea_browser_clear (itemview->htmlview);
}
g_assert (itemview->htmlview);
liferea_browser_clear (itemview->htmlview);

debug2 (DEBUG_GUI, "Setting item list layout mode: %d (auto=%d)", effectiveMode, itemview->autoLayout);

Expand Down Expand Up @@ -507,6 +498,14 @@ itemview_create (GtkWidget *window)
itemview->zoom = zoom;
itemview->currentLayoutMode = 1000; // something invalid

debug0 (DEBUG_GUI, "Creating HTML widget");
itemview->htmlview = liferea_browser_new (FALSE);
g_signal_connect (itemview->htmlview, "statusbar-changed",
G_CALLBACK (on_important_status_message), NULL);

/* Set initial zoom */
liferea_browser_set_zoom (itemview->htmlview, itemview->zoom/100.);

return itemview;
}

Expand Down
56 changes: 27 additions & 29 deletions src/ui/liferea_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -1318,20 +1318,7 @@ liferea_shell_create (GtkApplication *app, const gchar *overrideWindowState, gin
gtk_grid_attach_next_to (GTK_GRID (liferea_shell_lookup ("vbox1")), shell->toolbar, NULL, GTK_POS_TOP, 1,1);

gtk_widget_show_all(GTK_WIDGET(shell->toolbar));

g_signal_connect ((gpointer) liferea_shell_lookup ("itemtabs"), "key_press_event",
G_CALLBACK (on_key_press_event_null_cb), NULL);

g_signal_connect ((gpointer) liferea_shell_lookup ("itemtabs"), "key_release_event",
G_CALLBACK (on_key_press_event_null_cb), NULL);

g_signal_connect ((gpointer) liferea_shell_lookup ("itemtabs"), "scroll_event",
G_CALLBACK (on_notebook_scroll_event_null_cb), NULL);

g_signal_connect (G_OBJECT (shell->window), "delete_event", G_CALLBACK(on_close), NULL);
g_signal_connect (G_OBJECT (shell->window), "window_state_event", G_CALLBACK(on_window_state_event), shell);
g_signal_connect (G_OBJECT (shell->window), "configure_event", G_CALLBACK(on_configure_event), shell);
g_signal_connect (G_OBJECT (shell->window), "key_press_event", G_CALLBACK(on_key_press_event), shell);
render_init_theme_colors (GTK_WIDGET (shell->window));
g_signal_connect (G_OBJECT (shell->window), "style-updated", G_CALLBACK(liferea_shell_rebuild_css), NULL);

/* 3.) setup status bar */
Expand Down Expand Up @@ -1383,28 +1370,15 @@ liferea_shell_create (GtkApplication *app, const gchar *overrideWindowState, gin
icons_load ();

/* 9.) update and restore all menu elements */

liferea_shell_update_toolbar ();
liferea_shell_update_history_actions ();
liferea_shell_setup_URL_receiver ();
liferea_shell_restore_state (overrideWindowState);

gtk_widget_set_sensitive (GTK_WIDGET (shell->feedlistViewWidget), TRUE);

/* 10.) After main window is realized get theme colors and set up feed list */
// FIXME: this should not be necessary, but style-updated does not
// always fire before we get here
render_init_theme_colors (GTK_WIDGET (shell->window));

/* 10.) Set up feed list */
shell->feedlist = feedlist_create (feedListView);
g_signal_connect (shell->feedlist, "new-items",
G_CALLBACK (liferea_shell_update_unread_stats), shell->feedlist);
g_signal_connect (shell->feedlist, "items-updated",
G_CALLBACK (liferea_shell_update_node_actions), NULL);
g_signal_connect (shell->itemlist, "item-updated",
G_CALLBACK (liferea_shell_update_node_actions), NULL);
g_signal_connect (feedListView, "selection-changed",
G_CALLBACK (liferea_shell_update_node_actions), NULL);

/* 11.) Restore latest layout and selection */
conf_get_int_value (DEFAULT_VIEW_MODE, &mode);
Expand All @@ -1416,7 +1390,31 @@ liferea_shell_create (GtkApplication *app, const gchar *overrideWindowState, gin
g_free (id);
}

/* 12. Setup shell plugins */
/* 12. Setup shell window signals, only after all widgets are ready */
g_signal_connect (shell->feedlist, "new-items",
G_CALLBACK (liferea_shell_update_unread_stats), shell->feedlist);
g_signal_connect (shell->feedlist, "items-updated",
G_CALLBACK (liferea_shell_update_node_actions), NULL);
g_signal_connect (shell->itemlist, "item-updated",
G_CALLBACK (liferea_shell_update_node_actions), NULL);
g_signal_connect (feedListView, "selection-changed",
G_CALLBACK (liferea_shell_update_node_actions), NULL);

g_signal_connect ((gpointer) liferea_shell_lookup ("itemtabs"), "key_press_event",
G_CALLBACK (on_key_press_event_null_cb), NULL);

g_signal_connect ((gpointer) liferea_shell_lookup ("itemtabs"), "key_release_event",
G_CALLBACK (on_key_press_event_null_cb), NULL);

g_signal_connect ((gpointer) liferea_shell_lookup ("itemtabs"), "scroll_event",
G_CALLBACK (on_notebook_scroll_event_null_cb), NULL);

g_signal_connect (G_OBJECT (shell->window), "delete_event", G_CALLBACK(on_close), NULL);
g_signal_connect (G_OBJECT (shell->window), "window_state_event", G_CALLBACK(on_window_state_event), shell);
g_signal_connect (G_OBJECT (shell->window), "configure_event", G_CALLBACK(on_configure_event), shell);
g_signal_connect (G_OBJECT (shell->window), "key_press_event", G_CALLBACK(on_key_press_event), shell);

/* 13. Setup shell plugins */
if(0 == pluginsDisabled) {
shell->extensions = peas_extension_set_new (PEAS_ENGINE (liferea_plugins_engine_get_default ()),
LIFEREA_TYPE_SHELL_ACTIVATABLE, "shell", shell, NULL);
Expand Down

0 comments on commit 47e226c

Please sign in to comment.