[PD] Inconsistent creation in some objects

Hans-Christoph Steiner hans at at.or.at
Wed Nov 18 21:48:41 CET 2009


On Nov 18, 2009, at 2:02 PM, Mathieu Bouchard wrote:

> On Wed, 18 Nov 2009, Hans-Christoph Steiner wrote:
>
>> But in general, I think an object should instantiate regardless of  
>> the args so you can get help and having it throw findable errors,  
>> i.e. pd_error();
>
> no. instead you should make instantiation errors findable:

Sounds like a useful patch, is it in the patch tracker?

I think there is a reason to do both.  So if the object doesn't  
create, it should throw the error like in this patch.  But like  
IOhannes talked about, something like [netrecieve].  Currently, if  
there is a port conflict, it just doesn't create.  Instead it should  
create, and throw a pd_error() that explains the port conflict.  So  
both are very useful.

.hc

> ------------------8<--------cut-here--------8<------------------
> diff -ru pd-0.42-5-orig/src/s_print.c pd-0.42-5/src/s_print.c
> --- pd-0.42-5-orig/src/s_print.c        2009-11-18  
> 13:49:46.000000000 -0500
> +++ pd-0.42-5/src/s_print.c     2009-11-18 13:50:43.000000000 -0500
> @@ -132,7 +132,7 @@
>     offending or offended object around so the user can search for it
>     later. */
>
> -static void *error_object;
> +void *error_object;
> static char error_string[256];
> void canvas_finderror(void *object);
>
> diff -ru pd-0.42-5-orig/src/g_text.c pd-0.42-5/src/g_text.c
> --- pd-0.42-5-orig/src/g_text.c 2009-02-04 13:50:13.000000000 -0500
> +++ pd-0.42-5/src/g_text.c      2009-11-18 13:52:47.000000000 -0500
> @@ -86,6 +86,7 @@
>     t_binbuf *b)
> {
>     t_text *x;
> +    int error = 0;
>     int argc;
>     t_atom *argv;
>     newest = 0;
> @@ -97,7 +98,7 @@
>         if (!newest)
>         {
>             binbuf_print(b);
> -            post("... couldn't create");
> +           error = 1;
>             x = 0;
>         }
>         else if (!(x = pd_checkobject(newest)))
> @@ -111,6 +112,7 @@
>     {
>             /* LATER make the color reflect this */
>         x = (t_text *)pd_new(text_class);
> +        if (error) pd_error(x,"... couldn't create");
>     }
>     x->te_binbuf = b;
>     x->te_xpix = xpix;
> ------------------8<--------cut-here--------8<------------------
>
> it's as simple as that.
>
> _ _ __ ___ _____ ________ _____________ _____________________ ...
> | Mathieu Bouchard, Montréal, Québec. téléphone: +1.514.383.3801



----------------------------------------------------------------------------

There is no way to peace, peace is the way.       -A.J. Muste






More information about the Pd-list mailing list