Go Back   AC3D Forums > Technical > AC3D Developers
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 28th May 2004, 03:53 AM   #1
bsupnik
Junior Member
Member
 
Join Date: May 2004
Location: San Diego
Posts: 16
Default Memory Management and plugins

Hi Y'all,

First of all, Andy, great job witih the plugin system. It took less than two hours to write a basic exporter from AC3D to the X-Plane object format, and the vast majority of that was because I was stupidly and stubbornly trying to compile a Windows DLL plugin on my Mac with CodeWarrior (it does work, but the linker settings are non-obvious). I've been able to implement a number of features in the plugin very easily...very nice.

First question: is there a good cross-platform way to bring up a "select a file" type dialog box? I'm currently using the common file dialogs on Windows, but this code will have to be reimplemented on Unix/Linux. Is there a standard way to do this with Tcl or the plugin API?

Second question: when should I and when should I not free a linked list that I get back from the plugin APIs? Right now I never free them, which never crashes, but is probably bad house keeping.

*Cheers*
Ben

PS, my plugin reads and writes the x-plane object format and also provides some additional editing operations.
http://www.x-plane.com/
bsupnik is offline   Reply With Quote
Old 28th May 2004, 11:05 AM   #2
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,563
Default

Thanks Ben.

Use these - they will work on any platform:

Code:
Prototype char *ac_get_load_filename(char *title, char **suffix);
Prototype char *ac_get_import_filename(char *title, char **suffix);
Prototype char *ac_get_save_filename(char *title, char **suffix);
Prototype char *ac_get_export_filename(char *title, char **suffix);
e.g.

Code:
static void savepng_go()
{
char *filter[] = { "PNG files", "*.png", "All files", "*", NULL };

    char *fname = ac_get_export_filename("Save 3d win as png", filter);
    if (STRINGISEMPTY(fname))
        return;
    save_image(fname);
}
For linked lists, look in the plugin header - a comment at the prototype will tell you if you need to free the thing that's returned. Most of the functions don't, since they just return the pointer to the linked list e.g.

Code:
Prototype List *ac_object_get_vertexlist(ACObject *ob);
freeing this list would causes a swift crash.

If you are adding or removing stuff from objects - always use the other functions e.g. ac_object_add/remove... because they may do other stuff (like change vertex counters etc) - don't edit the lists directly - treat them as read only.

Andy
Andy is offline   Reply With Quote
Old 28th May 2004, 12:53 PM   #3
bsupnik
Junior Member
Member
 
Join Date: May 2004
Location: San Diego
Posts: 16
Default

ac_get_load_filename...perfect...and right under my nose! Thanks!

*cheers*
Ben
bsupnik is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -4. The time now is 11:54 AM.


AC3D Forum
(C) Inivis Limited 2020