| Re: [AD] destroy_bitmap after allegro_exit |
[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]
In reply to Vincent Penquerc'h <Vincent.Penquerch@xxxxxxxxxx>:
>Static objects are evil
>anyway :)
Hear, hear!
One possible solution:
void allegro_construct_destruct(int constructing)
{
static int count = 0;
if(constructing && !count++) allegro_init();
if(!constructing && !--count) allegro_exit();
}
Then call this in each object's ctor/dtor:
class global_bitmap {
private:
// ...
public:
global_bitmap() { allegro_construct_destruct(1); }
~global_bitmap() { allegro_construct_destruct(0); }
};
Of course, you would need to stop Allegro from registering allegro_exit
with atexit(). Is there any way to do this? If not, maybe we should add
one?
Bye for now,
--
Laurence Withers, lwithers@xxxxxxxxxx
http://www.lwithers.demon.co.uk/
Attachment:
signature.asc
Description: PGP signature
| Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |