diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-07-03 11:40:10 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-07-03 11:40:10 (GMT) |
commit | ecc4f670f1da84ac826515e88f9d5da8c0bc38a6 (patch) | |
tree | ef434b01f11487a3fca3b70094b98e6acb29c491 /macosx | |
parent | 9e275a46af3b084dd6191ad979a173bab25f417e (diff) | |
parent | a2d0ee1d83897b9b5d95ea1e6182cdc2448e9425 (diff) | |
download | tk-rfe_6c0d7aec67.zip tk-rfe_6c0d7aec67.tar.gz tk-rfe_6c0d7aec67.tar.bz2 |
merge core-8-6-branchrfe_6c0d7aec67
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/tkMacOSXDialog.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 3397f71..5bfcaf1 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -538,7 +538,7 @@ Tk_GetOpenFileObjCmd( if (len) { filename = [[[NSString alloc] initWithUTF8String:str] autorelease]; - [openpanel setNameFieldStringValue:filename]; + [openpanel setNameFieldStringValue:filename]; } break; case OPEN_MESSAGE: @@ -662,7 +662,12 @@ Tk_GetOpenFileObjCmd( if (directory) { [openpanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; } + /*check for file name, otherwise set to empty string; crashes with uncaught exception if set to nil*/ + if (filename) { [openpanel setNameFieldStringValue:filename]; + } else { + [openpanel setNameFieldStringValue:@""]; + } [openpanel beginSheetModalForWindow:parent completionHandler:^(NSInteger returnCode) { [NSApp tkFilePanelDidEnd:openpanel @@ -678,7 +683,13 @@ Tk_GetOpenFileObjCmd( if (directory) { [openpanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; } - [openpanel setNameFieldStringValue:filename]; + /*check for file name, otherwise set to empty string; crashes with uncaught exception if set to nil*/ + if (filename) { + [openpanel setNameFieldStringValue:filename]; + } else { + [openpanel setNameFieldStringValue:@""]; + } + modalReturnCode = [openpanel runModal]; #endif [NSApp tkFilePanelDidEnd:openpanel returnCode:modalReturnCode @@ -898,7 +909,12 @@ Tk_GetSaveFileObjCmd( if (directory) { [savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; } - [savepanel setNameFieldStringValue:filename]; + /*check for file name, otherwise set to empty string; crashes with uncaught exception if set to nil*/ + if (filename) { + [savepanel setNameFieldStringValue:filename]; + } else { + [savepanel setNameFieldStringValue:@""]; + } [savepanel beginSheetModalForWindow:parent completionHandler:^(NSInteger returnCode) { [NSApp tkFilePanelDidEnd:savepanel @@ -913,7 +929,12 @@ Tk_GetSaveFileObjCmd( if (directory) { [savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; } - [savepanel setNameFieldStringValue:filename]; + /*check for file name, otherwise set to empty string; crashes with uncaught exception if set to nil*/ + if (filename) { + [savepanel setNameFieldStringValue:filename]; + } else { + [savepanel setNameFieldStringValue:@""]; + } modalReturnCode = [savepanel runModal]; #if 0 NSLog(@"modal: %li", modalReturnCode); @@ -1047,6 +1068,10 @@ Tk_ChooseDirectoryObjCmd( callbackInfo->cmdObj = cmdObj; callbackInfo->interp = interp; callbackInfo->multiple = 0; + /*check for directory value, set to root if not specified; otherwise crashes with exception because of nil string parameter*/ + if (!directory) { + directory = @"/"; + } parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); if (haveParentOption && parent && ![parent attachedSheet]) { parentIsKey = [parent isKeyWindow]; |