Hello, I’m making a browser with WebKit, GTK, and Vala. I am implementing tabs via a Gtk.Notebook
, however I get a segfault when adding pages to it via a callback event. I can add them during my ApplicationWindow
subclass constructor as normal. Here are some relevant snippets:
/* class based on Gtk.ApplicationWindow */
public ApplicationWindow (Sail.Application app, WebKit.Settings settings) {
application = app;
this.settings = settings;
open_tab ("https://www.youtube.com/"); //Opens tab fine
open_tab (null); //Opens tab fine
}
// Connected to Gtk.Button.clicked via .ui file, fails when handled
public void open_tab (string? uri) {
Tab tab = new Tab ();
WebView view = new WebView (tab, uri);
tab_bar.append_page (view, tab); // Segfaults here
var page = tab_bar.get_page (view);
page.tab_expand = true;
page.tab_fill = true;
}
/* class based on WebKit.WebView */
public WebView (Tab tab, string? uri) {
const string DEFAULT_PAGE = "https://search.brave.com/";
this.tab = tab;
notify["favicon"].connect ((s, p) => {
tab.set_icon (get_favicon ());
});
load_uri (uri != null ? uri : DEFAULT_PAGE);
}
Any and all help/questions are appreciated!