28th May 2004, 03:53 AM | #1 |
Junior Member
Member
Join Date: May 2004
Location: San Diego
Posts: 16
|
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/ |
28th May 2004, 11:05 AM | #2 |
Administrator
Professional user
Join Date: Jun 2003
Posts: 4,565
|
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); 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); } Code:
Prototype List *ac_object_get_vertexlist(ACObject *ob); 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 |
28th May 2004, 12:53 PM | #3 |
Junior Member
Member
Join Date: May 2004
Location: San Diego
Posts: 16
|
ac_get_load_filename...perfect...and right under my nose! Thanks!
*cheers* Ben |
|
|