RE: [AD] `c' in MSG_END

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Clever, this covers everything.

The attached ZIP contains the appropriate patch and
an example (completely tested) that uses the new
feature of the patch.

--
David Alfredo Capello Pirenjak
davidcapello@xxxxxxxxxx - http://come.to/davidcapello/

----- Original Message ----- 
From: Peter Wang <tjaden@xxxxxxxxxx>
To: <conductors@xxxxxxxxxx>
Sent: Saturday, February 17, 2001 9:45 AM
Subject: Re: [AD] `c' in MSG_END


> David A. Capello <davidcapello@xxxxxxxxxx> wrote:
> > This patch is so that when sending a message MSG_END, the
> > parameter `c' it is the index of the object that I produce
> > the exit. 
> 
> > This is useful for if the doubts an object wants
> > to have different answers depending on the object that I
> > produce the exit (for e.g.: press "ok" sprite_proc creates
> > a bitmap, press "cancel" sprite_proc it doesn't create
> > anything...).
> 
> I still think this particular example is better done using the
> return value of `do_dialog'.  However..
> 
> Bob convinced me in a private message:
> > Rather, it's so that the widgets can have different behaviours
> > depending on which widget ended the dialog (or so the original
> > auther wrote).
> 
> This might be useful in different cases.  I was about to apply the
> patch, but it's slightly wrong.
> 
> diff -Nu --recursive allegro.old/src/gui.c allegro.new/src/gui.c
> --- allegro.old/src/gui.c Fri Feb  2 14:16:08 2001
> +++ allegro.new/src/gui.c Thu Feb 15 22:38:58 2001
> @@ -1039,7 +1039,7 @@
>     int obj;
>  
>     /* send the finish messages */
> -   dialog_message(player->dialog, MSG_END, 0, &player->obj);
> +   dialog_message(player->dialog, MSG_END, player->obj, &player->obj);
>  
>     /* remove the double click handler */
>     gui_install_count--;
>     
> If you only use "return D_CLOSE" to close a dialog then it would be
> fine.  But if you use the `init_dialog' and `update_dialog'
> functions, you could `shutdown_dialog' at any time, so `player->obj'
> will not contain the right value.
> 
> I haven't tested this, so I might have messed up..
> 
> 
> BTW, does anyone know why `shutdown_dialog' does this at the start:
> 
>    dialog_message(player->dialog, MSG_END, 0, &player->obj);
>    ...
> 
> then this at the end:
> 
>    ...
>    obj = player->obj;
>    free(player);
>    return obj;
> 
> instead of just:
> 
>    dialog_message(player->dialog, MSG_END, 0, &obj);
>    ...
>    free(player);
>    return obj;
> 
> AFAICT, in between, `player->obj' is not used at all.  
> 
> -- 
> tjaden@xxxxxxxxxx - http://www.psynet.net/tjaden/
> KEDOPHOBIA (ked oh FO be uh), n.  The fear of having one's sneakers eaten
> by the teeth on the escalator.  -- Rich Hall, "Sniglets"



Attachment: msgend.zip
Description: Zip compressed data



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/