This error occurs when starting my program.
(exec:4287): Gtk-CRITICAL **: gtk_widget_show_all: assertion 'GTK_IS_WIDGET (widget)' failed
I am writing in the language of Vala. Here is the code of the method after which the crashes appeared:
public static string select(){ string output; var dialog = new Gtk.FileChooserDialog("Open File", ClassMain.mainWindow, Gtk.FileChooserAction.OPEN, Gtk.ResponseType.CANCEL, Gtk.ResponseType.CANCEL, Gtk.ResponseType.ACCEPT, Gtk.ResponseType.ACCEPT); if(dialog.run() == Gtk.ResponseType.ACCEPT) { output = (dialog.get_filename()); dialog.destroy(); return output; } return ""; }
When compiling, you can notice a set of errors (warning), which, however, do not interfere with compilation (but in vain):
/home/ancient/code/vala/VGIDE/file.vala.c: In function 'class_file_select': /home/ancient/code/vala/VGIDE/file.vala.c:61:2: warning: passing argument 4 of 'gtk_file_chooser_dialog_new' makes pointer from integer without a cast [enabled by default] _tmp1_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new ("Open File", _tmp0_, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_RESPONSE_CANCEL, GTK_RESPONSE_CANCEL, GTK_RESPONSE_ACCEPT, GTK_RESPONSE_ACCEPT, NULL); ^ In file included from /usr/include/gtk-3.0/gtk/gtk.h:99:0, from /home/ancient/code/vala/VGIDE/file.vala.c:9: /usr/include/gtk-3.0/gtk/gtkfilechooserdialog.h:63:12: note: expected 'const gchar *' but argument is of type 'int' GtkWidget *gtk_file_chooser_dialog_new (const gchar *title, ^
PS Please add the tag "Vala", since this is the main topic of this topic.
UPD: After fix: (an error when starting the same)
file.vala:7.4-7.12: warning: Gtk.Stock has been deprecated since 3.10 file.vala:8.4-8.12: warning: Gtk.Stock has been deprecated since 3.10 /home/ancient/code/vala/VGIDE/file.vala.c: In function 'class_file_select': /home/ancient/code/vala/VGIDE/file.vala.c:61:2: warning: 'GtkStock' is deprecated [-Wdeprecated-declarations] _tmp1_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new ("Open File", _tmp0_, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); ^ /home/ancient/code/vala/VGIDE/file.vala.c:61:2: warning: 'GtkStock' is deprecated [-Wdeprecated-declarations] Compilation succeeded - 2 warning(s)
A. Replaced all the drains with lines with the appropriate names and disappeared when compiling errors. But the crash indicated at the beginning of the topic still happens.