Re: [AD] al_acknowledge_display_disconnected

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


On Tue, 22 May 2012 10:40:23 -0600
Trent Gamblin <trent@xxxxxxxxxx> wrote:

> On 2012-05-22, at 2:16 AM, Peter Wang wrote:
> > What does al_acknowledge_display_disconnected do?
> 
> Just some housekeeping, but a display being disconnected is like a
> drawing halt, you can't do any opengl calls until it's handled. So
> you have:
> 
> gotDisconnectNotification() {
>    sendAllegroEvent(DISCONNECT);
>    waitForAcknowledge();
>    housekeeping();
> }
> 
> > Can you put the ALLEGRO_DISPLAY into an no-op state and send an
> > event? Then the user can call al_destroy_display on it as usual, or
> > continue obliviously (probably uselessly).
> > 
> > Peter
> 
> No, it has to be handled. Right now it waits up to 5 seconds, after
> that it just goes on as if the user acknowledged. Which will mean a
> crash in most cases.
> 

There are 3 ways to do this, from the API point of view:

1) case DISCONNECT:
    al_acknowledge_display_disconnected(d);
    // this also destroyed the display

2) case DISCONNECT:
    al_acknowledge_display_disconnected(d);
    // be oblivious because d has its vtable filled with dummy methods
    // now who will not access the OpenGL context
    ...
    al_destroy_display(d);

3) case DISCONNECT:
    al_destroy_display(d);

You suggested way 1) and I think what Peter meant is way 2). Personally
I think I'd prefer way 3, it keeps the al_create_display /
al_destroy_display symmetry and there's no (possibly confusing) new
function to describe in the docs.




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