[PD-dev] popup - more weirdness

B. Bogart ben at ekran.org
Tue Oct 19 21:49:31 CEST 2004


Hey all,

I'm still puzzeling over this one, but I get the impression it has a lot to do 
with what is happening in PD than in my own external. I'm hoping someone may 
have already come accross this and could save me some time. If not I'll keep 
puzzeling.

So it seems that in certain circumstances (see patch attached from Oliver) popup 
will leak some of its data out into the patch. The patch has number of comment 
objects and a few message boxes:

comment: blah blah blah name is: example
message: name changed
message: name example
message: name another

The name of the popup is "example" by default.

When you change the name of the popup via "name changed" everything seems fine, 
until you save the patch and see that somehow the messagebox "name example" has 
magically changed into "name changed" Also odd is that the last atom in the 
first comment changes "example" also to "changed".

It is as if setting the atom in popup to change the name is also setting data 
elseware in PD. I don't think I'm doing anything special in popup... This 
happens on OSX and linux. I've put the patches that result from each step of the 
popup-bug.pd patch popup-bug-1.pd first then popup-bug-2.pd next at the bottom 
of this email for reference.

Here is the structure:
typedef struct _popup
{
      t_object x_obj;

      t_glist * x_glist;
      t_outlet* out2;
      int x_rect_width;
      int x_rect_height;
      t_symbol*  x_sym;

      int x_height;
      int x_width;

      int x_num_options;
      t_symbol* x_popup_colour;
      t_symbol* x_popup_name;

      t_symbol* x_popup_options[MAX_OPTIONS];

} t_popup;

Where x_popup_name is the variable the "name" selector is setting.

The method that sets the name is:
static void popup_name(t_popup* x, t_symbol *name)
{
         DEBUG(post("name start");)
         DEBUG(post("x_popup_name: %s, name: %s", x->x_popup_name->s_name, 
name->s_name);)

         x->x_popup_name->s_name = name->s_name;
         sys_vgui(".x%x.c.s%x configure -text \"%s\"\n", x->x_glist, x, 
name->s_name);
}

Here is the function to save the patch is:
static void popup_save(t_gobj *z, t_binbuf *b)
{
         DEBUG(post("save start");)

         int i;
     t_popup *x = (t_popup *)z;

     binbuf_addv(b, "ssiisiiss", gensym("#X"),gensym("obj"),
                 x->x_obj.te_xpix, x->x_obj.te_ypix ,
                 gensym("popup"), x->x_width, x->x_height, x->x_popup_colour, 
x->x_popup_name);
         /* Loop for menu items */
         for(i=0 ; i<x->x_num_options ; i++)
         {
                 binbuf_addv(b, "s", x->x_popup_options[i]);
         }
     binbuf_addv(b, ";");

     DEBUG(post("save end");)
}

And finally my setup looks like:

void popup_setup(void) {

     DEBUG(post("setup start");)

     popup_class = class_new(gensym("popup"), (t_newmethod)popup_new, 0,
                                 sizeof(t_popup),0,A_GIMME,0);

         class_addmethod(popup_class, (t_method)popup_output,
                                                                   gensym("output"),
                                                                   A_DEFFLOAT,
                                                                   0);

         class_addmethod(popup_class, (t_method)popup_name,
                                                                   gensym("name"),
                                                                   A_DEFSYMBOL,
                                                                   0);

         class_addmethod(popup_class, (t_method)popup_options,
 
gensym("options"),
                                                                   A_GIMME,
                                                                   0);

         class_addmethod(popup_class, (t_method)popup_bgcolour,
 
gensym("bgcolour"),
                                                                   A_DEFSYMBOL,
                                                                   0);
         class_doaddfloat(popup_class, (t_method)popup_iselect);

     class_setwidget(popup_class,&popup_widgetbehavior);
#if PD_MINOR_VERSION >= 37
     class_setsavefn(popup_class,&popup_save);
#endif

         post("Popup v0.1(test) Ben Bogart.");
}

I'm really lost as to how I could be setting values outside of my external code. 
Am I missing any keywords? Am I using any reserved variables? am I simply doing 
things I should not be???

Thanks all.
Ben Bogart

popup-bug-1.pd:
#N canvas 390 543 625 324 12;
#X obj 112 254 popup 124 25 #ffffff changed option;
#X msg 112 148 name changed;
#X msg 131 178 name changed;
#X text 40 46 3.) try to change it back to "example" -> doesn't work
;
#X text 40 61 4.) save the patch \, close it and re-open it.;
#X msg 150 211 name another;
#X text 40 78 5.) do the same with "another";
#X text 41 106 6.) have a look at the changing of the last word in
comment;
#X text 522 106 1.);
#X text 40 30 2.) click the message "name changed";
#X text 40 13 1.) the popup's original name is: changed;
#X connect 1 0 0 0;
#X connect 2 0 0 0;
#X connect 5 0 0 0;

popup-bug-2.pd:
#N canvas 390 543 629 328 12;
#X obj 112 254 popup 124 25 #ffffff another option;
#X msg 112 148 name another;
#X msg 131 178 name another;
#X text 40 46 3.) try to change it back to "example" -> doesn't work
;
#X text 40 61 4.) save the patch \, close it and re-open it.;
#X msg 150 211 name another;
#X text 40 78 5.) do the same with "another";
#X text 41 106 6.) have a look at the changing of the last word in
comment;
#X text 522 106 1.);
#X text 40 30 2.) click the message "name changed";
#X text 40 13 1.) the popup's original name is: another;
#X connect 1 0 0 0;
#X connect 2 0 0 0;
#X connect 5 0 0 0;



-------- Original Message --------
Subject: Re: [PD] Re: [PD-dev] crashes with "popup" when using inside GOP
Date: Sun, 17 Oct 2004 23:41:39 +0200
From: oliver <oliver at klingt.org>
Reply-To: oliver at klingt.org
To: B. Bogart <ben at ekran.org>
References: <49719.132.208.20.8.1096387413.squirrel at 132.208.20.8>
<4162C2FE.9000005 at klingt.org> <4162F10A.4040303 at ekran.org>
<4163040F.20208 at klingt.org> <4171C75F.60509 at ekran.org>

hi, ben

indeed a very strange bug i found with popup v.0.1

when a popup is created, you give it a name, like "example".
now you have the possibility to give it a [name( message and
change the name which is then displayed on the popup.

now let's say you change it to "changed". works ok. but it's
not possible to change it back to "example".

thus, saving the patch also changes the popup's name

what's even more weirder, is that message boxes that had the
term "example" in them, display the term "changed" instead
when the patch is re-opened (the same goes for comments,
except if the term is quoted!)

BTW: this demonstration patch works only once, because with
every new saving it gets more and more messed up ;-)

ciao

oliver


B. Bogart wrote:

> Hey Oliver,
> 
> Can you possibly get gdb or some kind of debugger do I know why things 
> are
> crashing when you use popup in a gop? (since it works on the other 
> platforms)
> 
> Also I just commited changes to popup that fix a bug and there is also 
> an extra
> agrument for height. This will break patched using the old popup. 
> 
> that's ok, since i always edited the width by hand...
> 
> 
> I've called
> this one v0.1 (I think the other was called v0)
> 
> Lemme know how it works for you.
> 
> Ben
> 
> oliver wrote:
> |
> |
> | B. Bogart wrote:
> |
> |> Hey Oliver,
> |>
> |> Hmmm, I've been using popup in GOPs since it was written on OSX and
> |> linux without delete problems. You're not, by any chance, trying to
> |> send a message to popup via a loadbang when the abstraction loads? Try
> |> putting just popup w/out anything else in a gop and see if that still
> |> crashes on delete. If that works you can try copying the cutting and
> |> pasting the popup to put it on the top and then reconnect it. I did
> |> have some issues with deletion order with entry (which shares a lot of
> |> code w/ popup).
> |>
> |> I'm using pd 0.37.1 on OSX and 0.37.1 TEST6 on linux... what are your
> |> minor version numbers? "Help" -> "About PD"
> |
> |
> | mine is pd 0.37.2, for whatever reason (don't like to change things too
> | often)
> | the only thing i needed the GOP for was the height thing. i hoped that
> | with the boundaries of a GOP i could reduce it like it does with other
> | GUIs. unfortunately it doesn't work, as "popup" seems to be on top of
> | all other GUI restrictions ;-)
> |
> | so, the GOP thing just isn't that important for my request. besides: 
> the
> | GOP using "popup" didn't have anything else but send/receive objects
> | connected to its in-/outlets. no loadbang used.
> |
> |>
> |> As for feature requests I can put it on the list of things to do, but
> |> saving the height as a creation argument causes the issue of patch
> |> compatibility. The arguments are saved in the patch, so the argument
> |> list would be compatible with the new popup but not the old one. A
> |> possibility is a message that sets the height via message, but when
> |> reopening the patch the new height would be lost.
> |
> |
> | wouldn't be that bad, as far as i'm concerned. i understand your 
> concern
> | compatibility problems. (but then: popup is quite a new external, 
> and as
> | far as i reserached, it wasn't ever published on PD-announce...)
> |
> |>
> |> How many pixels high is the popup on windows? Looks about the same on
> |> OSX and Linux. (24 pixels high on linux)
> |
> |
> | can't quite tell. i personally use to make my patches with font size 
> 10,
> | which is quite small as i like to put many things (GUIs) inside it.
> | therefore my need to save visual space
> |
> |>
> |> As for the widget coming up on top, this is just how tcl/tk draws
> |> widgets on canvases.
> |
> |
> | mmh, i think i didn't quite understand that part. what is a "widget" ?
> | the thing is: if "popup" behaved like the IEM-GUIs (the GUI that's
> | created last covers all the things created before) it would also be 
> fine
> | for me. the problem is that "popup" always stays topmost...
> |
> | anyway, a cool external, and in general, it's working perfect !
> |
> | a great contribution to the PD externals family
> |
> | ciao
> |
> | oliver
> |
> |>
> |> Thanks for the feedback, please get back to me when you try what I
> |> suggest.
> |>
> |> Ben
> |>
> |> oliver wrote:
> |>
> |>> hi, list, ben
> |>>
> |>> i discovered, that the popup- menu crashes PD when used inside a GOP
> |>> and the GOP is closed (or deleted). so, if you close a patch using a
> |>> GOP with "popup" PD will also quit.
> |>>
> |>> (WinXP with PD 0.37)
> |>>
> |>> another thing about "popup":
> |>>
> |>> it would be very cool to give it a vertical size argument. at the
> |>> moment you can only define the width of it, but for my needs it's
> |>> very often too big in height.
> |>> another small "problem" is that it stays on top of all other GUI
> |>> elements of PD, no matter when it's created
> |>>
> |>> just some suggestions for a possible update ;-)
> |>>
> |>> oliver
> |>>
> |>
> |> _______________________________________________
> |> PD-list at iem.at mailing list
> |> UNSUBSCRIBE and account-management ->
> |> http://iem.at/cgi-bin/mailman/listinfo/pd-list
> |>
> |>
> |

-- 


////////////////////////////////////////////////////////
\\\\\\\\\\\\\ http://klingt.org/ground/lift \\\\\\\\\\\\
///////// http://klingt.org/executive-ensemble /////////
\\\\\\\\\\\\\ http://klingt.org/~oliver/prb \\\\\\\\\\\\
////////////////////////////////////////////////////////
\\\\\\\\ LIVE-BUILDER (music improvisation tool): \\\\\\
/////// http://klingt.org/~oliver/pd/live-builder //////
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: popup-bug.pd
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20041019/17167716/attachment.asc>


More information about the Pd-dev mailing list