summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macosx/tkMacOSXDialog.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index 3397f71..9d78ce6 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,6 +909,12 @@ Tk_GetSaveFileObjCmd(
if (directory) {
[savepanel 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) {
+ [savepanel setNameFieldStringValue:filename];
+ } else {
+ [savepanel setNameFieldStringValue:@""];
+ }
[savepanel setNameFieldStringValue:filename];
[savepanel beginSheetModalForWindow:parent
completionHandler:^(NSInteger returnCode)
@@ -913,7 +930,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 +1069,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];