[PD] closing PD and object destructor

Krzysztof Czaja czaja at chopin.edu.pl
Mon Sep 17 11:14:32 CEST 2001


hi,

"Joseph A. Sarlo" wrote:
> 
> Has anyone else noticed that if PD is closed (without closing the patch
> window) the objects' destructors are not called? Is there some reason for
> this?

Maybe the reason is that to orderly exit one needs not only to
call all destructors, but also to close all open canvases and,
for any dirty topcanvas, ask user if a file should be saved.  If
I understand correctly, such a feature is planned for the future,
and therefore using some temporary mechanism to be replaced later
was considered inconvenient.  Moreover it is unnecessary to free
ordinary resources (memory, fds) at program termination.  However,
sometimes one could want something else, of course.

The main point is that we do not need any special mechanism for
calling all destructors, because, during closing of a toplevel
canvas, destructors of all its objects are invoked (including
those in subcanvases).

But anyway, I think forcing all canvases to close, with no
questions asked, is really easy and safe -- at least for a regular
termination sequence started from quit menu/shortcut (quit message
to pdclass).  The only two additions needed are:

1. to define a `close all' function in g_canvas.c, for example:

+// temporary version: works as expected only for nonzero argument
+void canvas_closeall(t_floatarg force)
+{
+    t_canvas *x;
+    for (x = canvas_list; x; x = x->x_next)
+        canvas_menuclose(x, force);
+}

2. to call this function in s_inter.c:

 void glob_quit(void *dummy)
 {
+     canvas_closeall(1);

Krzysztof



More information about the Pd-list mailing list