From 61276a830613eb1ed26aa90b4572e80b0caa64f3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 23 Jan 2016 19:41:53 +0000 Subject: Better repair of parentIsKey (backported from Tk 8.6). Problem was introduced in (apparently ill-merged) commit [3f634e02ece26dff] --- macosx/tkMacOSXDialog.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 0f7ef3a..84fef94 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -190,6 +190,7 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) { Tcl_Obj **objv, **tmpv; int objc, result = Tcl_ListObjGetElements(callbackInfo->interp, callbackInfo->cmdObj, &objc, &objv); + if (result == TCL_OK && objc) { tmpv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * (objc + 2)); memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc); @@ -212,18 +213,22 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) { ckfree((char *)callbackInfo); } } -- (void)tkAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode - contextInfo:(void *)contextInfo { + +- (void) tkAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode + contextInfo: (void *) contextInfo +{ AlertCallbackInfo *callbackInfo = contextInfo; if (returnCode >= NSAlertFirstButtonReturn) { Tcl_Obj *resultObj = Tcl_NewStringObj(alertButtonStrings[ alertNativeButtonIndexAndTypeToButtonIndex[callbackInfo-> typeIndex][returnCode - NSAlertFirstButtonReturn]], -1); + if (callbackInfo->cmdObj) { Tcl_Obj **objv, **tmpv; int objc, result = Tcl_ListObjGetElements(callbackInfo->interp, callbackInfo->cmdObj, &objc, &objv); + if (result == TCL_OK && objc) { tmpv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * (objc + 2)); memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc); @@ -395,9 +400,7 @@ Tk_GetOpenFileObjCmd( NSMutableArray *fileTypes = nil; NSOpenPanel *panel = [NSOpenPanel openPanel]; NSInteger modalReturnCode = modalError; -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 BOOL parentIsKey = NO; -#endif TkInitFileFilters(&fl); for (i = 1; i < objc; i += 2) { @@ -513,10 +516,10 @@ Tk_GetOpenFileObjCmd( callbackInfo->multiple = multiple; parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); if (haveParentOption && parent && ![parent attachedSheet]) { + parentIsKey = [parent isKeyWindow]; #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 [panel beginSheetForDirectory:directory file:filename - parentIsKey = [parent isKeyWindow]; types:fileTypes modalForWindow:parent modalDelegate:NSApp @@ -545,12 +548,12 @@ Tk_GetOpenFileObjCmd( contextInfo:callbackInfo]; } result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR; - if (typeVariablePtr && result == TCL_OK) { - /* - * The -typevariable option is not really supported. if (parentIsKey) { [parent makeKeyWindow]; } + if (typeVariablePtr && result == TCL_OK) { + /* + * The -typevariable option is not really supported. */ Tcl_SetVar2(interp, Tcl_GetString(typeVariablePtr), NULL, @@ -604,7 +607,6 @@ Tk_GetSaveFileObjCmd( TkInitFileFilters(&fl); for (i = 1; i < objc; i += 2) { - parentIsKey = NO; if (Tcl_GetIndexFromObjStruct(interp, objv[i], saveOptionStrings, sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) { goto end; @@ -718,10 +720,10 @@ Tk_GetSaveFileObjCmd( callbackInfo->multiple = 0; parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); if (haveParentOption && parent && ![parent attachedSheet]) { + parentIsKey = [parent isKeyWindow]; #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 [panel beginSheetForDirectory:directory file:filename - parentIsKey = [parent isKeyWindow]; modalForWindow:parent modalDelegate:NSApp didEndSelector: @@ -1177,7 +1179,7 @@ Tk_MessageBoxObjCmd( contextInfo:callbackInfo]; } result = (modalReturnCode >= NSAlertFirstButtonReturn) ? TCL_OK : TCL_ERROR; - end: + end: [alert release]; if (parentIsKey) { [parent makeKeyWindow]; -- cgit v0.12 From 3000865931e61dd77e966d0af27b4c86dcdbfaad Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 23 Jan 2016 19:46:08 +0000 Subject: (cherry-pick): Fixed bug [9e606527af] - && instead of & used in generic/tkOption.c --- generic/tkOption.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkOption.c b/generic/tkOption.c index bff799b..17989f8 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.c @@ -559,7 +559,7 @@ Tk_GetOption( count -= levelPtr[-1].bases[currentStack]; } - if (currentStack && CLASS) { + if (currentStack & CLASS) { nodeId = winClassId; } else { nodeId = winNameId; -- cgit v0.12