Fix segmentation fault if no file has been opened

This commit is contained in:
Moritz Lipp 2010-12-26 11:10:10 +01:00
parent b8aa82b4b1
commit 726766549e
2 changed files with 8 additions and 3 deletions

View file

@ -19,7 +19,7 @@ cb_destroy(GtkWidget* widget, gpointer data)
gboolean
cb_draw(GtkWidget* widget, GdkEventExpose* expose, gpointer data)
{
if(!widget) {
if(!widget || !Zathura.document) {
return false;
}

View file

@ -10,6 +10,7 @@
bool
init_zathura()
{
/* UI */
if(!(Zathura.UI.session = girara_session_create())) {
goto error_out;
}
@ -23,7 +24,7 @@ init_zathura()
Zathura.UI.statusbar.page_number = NULL;
Zathura.UI.drawing_area = NULL;
/* UI */
/* statusbar */
Zathura.UI.statusbar.file = girara_statusbar_item_add(Zathura.UI.session, TRUE, TRUE, TRUE, NULL);
if(!Zathura.UI.statusbar.file) {
goto error_free;
@ -41,13 +42,17 @@ init_zathura()
girara_statusbar_item_set_text(Zathura.UI.session, Zathura.UI.statusbar.file, "[No Name]");
/* drawing area */
Zathura.UI.drawing_area = gtk_drawing_area_new();
if(!Zathura.UI.drawing_area) {
goto error_free;
}
gtk_widget_show(Zathura.UI.drawing_area);
gtk_widget_modify_bg(Zathura.UI.drawing_area, GTK_STATE_NORMAL,
&(Zathura.UI.session->style.default_background));
g_signal_connect(G_OBJECT(Zathura.UI.drawing_area), "expose-event", G_CALLBACK(cb_draw), NULL);
gtk_widget_show(Zathura.UI.drawing_area);
/* set view */
if(!girara_set_view(Zathura.UI.session, Zathura.UI.drawing_area)) {