saveas_dialog crashes max

Feb 11, 2014 at 6:53am

saveas_dialog crashes max

hi there,
what i eventually want to come up with, is a dialog that lets the user select a folder (like [savedialog fold] in max).
so i’m experimenting with saveas_dialog() and saveasdialog_extended() – both seem to have severe problems (or maybe it’s just me?) – Max 6.1.6 & SDK 6.1.4 on mac os 10.6

in the stripped down example below both calls to saveas_dialog or saveasdialog_extended crash badly – even without the time for a crash report or anything – where as the call to open_dialog() works fine.

something similar appeared here http://cycling74.com/forums/topic/alternative-to-saveasdialog_extendedfilename-path-outtype-filetype-1/
but unfortunately didn’t lead anywhere.

does anybody see what’s wrong?
thanks,
volker.

#include "ext.h"
#include "ext_obex.h"
#include "ext_common.h"


static t_class *myObj_class;
typedef struct {
	t_object b_ob;
} t_myObj;


void *myObj_new( t_symbol *s, long argc, t_atom *argv);
void myObj_saveme(t_myObj *x);
void myObj_dosave(t_myObj *x);


int C74_EXPORT main(void) {
	t_class *c = class_new("testSaveas", (method)myObj_new, 0, (short)sizeof(t_myObj), 0L, A_GIMME, 0L);	
	class_addmethod(c, (method)myObj_saveme, "bang", 0);
	class_register(CLASS_BOX, c);
	myObj_class = c;
	return 0;
}


void myObj_saveme(t_myObj *x) {
	defer_low(x, (method)myObj_dosave, 0, 0, 0L);
}


void myObj_dosave(t_myObj *x) {
	short		pathID;
	char		filename[MAX_FILENAME_CHARS];	
	t_fourcc	type;
	

	// open_dialog(filename, &pathID, &type, 0L, 0);		// works fine
	saveas_dialog(filename, &pathID, NULL);				// <-- crash
	//saveasdialog_extended(filename, &pathID, &type, 0L, 0); //<- crash
	
	post("name: %s -- pathID: %d", filename, pathID);
}


void *myObj_new(t_symbol *s, long argc, t_atom *argv) {
	t_myObj *x = object_alloc(myObj_class);	
	return x;
}
#280727
Feb 11, 2014 at 1:53pm

Hi,
Perhaps, you should use a “t_fourcc” instead of 0L for the filetypelist ?
Best

#280784
Feb 11, 2014 at 11:57pm

Perhaps, you should use a “t_fourcc” instead of 0L for the filetypelist ?

saveas_dialog() uses no typelist.
and for saveasdialog_extended() it doesn’t prevent the crash either.
:>(

#280819
Feb 13, 2014 at 10:54am

Hi Volker,

on my platform (MacOS 10.9 running Max/MSP 6.1.6 64-bit) this seems to work without crashing:

void myObj_dosave(t_myObj *x)
{
    char        filename[MAX_FILENAME_CHARS];
    short       pathID;
    t_fourcc    type;
    t_fourcc    typelist[2] = { 'JSON', 'TEXT' };
    short       typecount = 2;
    
    strcpy(filename, "untitled");
    if (saveasdialog_extended(filename, &pathID, &type, typelist, typecount)) {
        return;
    }
    post("filename: %s -- pathID: %d", filename, pathID);

    // keep going...
}

Let me know if it works for you too…

Best

- Luigi

#281021
Feb 13, 2014 at 12:44pm

hi luigi

thanks for looking into this! and yes, your example works here, too.
i started poking round a little and the types and typelist stuff can all be zero.
but strcpy seems to make the difference (which makes sense, as this defines the default filename which is presented in the dialog).

actually this is what i want to get rid off in the end, to end up with a dialog, where the user can select a folder (not a file). somebody knows, how to get that?

all the best,
volker.

#281034

You must be logged in to reply to this topic.