MDI Trobules

the function gnome_mdi_add_child (and it's callers) have a problem.

If the function associated with the CREATE_VIEW signal doesn't create 
the view (in balsa this happens when a mailbox can't be opened) then a 
NULL pointer is appened to the list of views, causing havoc.

Anon CVS not available, therefore no patch but:

in the function gnome_mdi_add_view:

gint gnome_mdi_add_view(GnomeMDI *mdi, GnomeMDIChild *child) {
  GtkWidget *view;
  gint ret = TRUE;

  view = gnome_mdi_child_add_view(child);
+  if (!view)
+    return 0;
  gtk_signal_emit(GTK_OBJECT(mdi), mdi_signals[ADD_VIEW], view, &ret);

and in the function gnome_mdi_child_add_view:

GtkWidget *gnome_mdi_child_add_view(GnomeMDIChild *mdi_child) {
  GtkWidget *view;

  gtk_signal_emit (GTK_OBJECT (mdi_child), mdi_child_signals[CREATE_VIEW], &view);
+  if (!view)
+    return 0;
  mdi_child->views = g_list_append(mdi_child->views, view);

  gtk_object_set_data(GTK_OBJECT(view), "GnomeMDIChild", mdi_child);

should cure this.

The basic problem is that it's possible to connect to the CREATE_VIEW 
signal, but don't connect to the ADD_VIEW signal. Otherwise the
ADD_VIEW signal could set the return value to FALSE and the patch
isn't necessary. But at least balsa doesn't do this and i can imagine
other applications will also fail to do so.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]