bpo-44828: Avoid tkinter file dialog failure on macOS 12 Monterey (GH… · python/cpython@f19c1a1 (original) (raw)

``

1

`+

--- tk8.6.11/macosx/tkMacOSXDialog.c 2020-12-31 01:46:07.000000000 +0000

`

``

2

`+

+++ tk8.6.11-patched/macosx/tkMacOSXDialog.c 2021-10-28 15:13:03.000000000 +0000

`

``

3

`+

@@ -221,7 +221,7 @@

`

``

4

`+

returnCode: (NSModalResponse) returnCode

`

``

5

`+

contextInfo: (void *) contextInfo

`

``

6

`+

{

`

``

7

`+

`

``

8

`+

`

``

9

+

``

10

`+

if (returnCode == modalOK) {

`

``

11

`+

Tcl_Obj *resultObj;

`

``

12

`+

@@ -266,7 +266,7 @@

`

``

13

`+

`

``

14

`+

contextInfo: (void *) contextInfo

`

``

15

`+

{

`

``

16

`+

`

``

17

`+

`

``

18

+

``

19

`+

if (returnCode >= NSAlertFirstButtonReturn) {

`

``

20

`+

Tcl_Obj *resultObj = Tcl_NewStringObj(alertButtonStrings[

`

``

21

`+

@@ -350,49 +350,41 @@

`

``

22

`+

FilePanelCallbackInfo *callbackInfo)

`

``

23

`+

{

`

``

24

`+

NSInteger modalReturnCode;

`

``

25

`+

`

``

26

+

``

27

`+

`

``

28

`+

`

``

29

`+

`

``

30

`+

`

``

31

`+

`

``

32

`+

`

``

33

`+

`

``

34

`+

`

``

35

`+

`

``

36

`+

`

``

37

`+

`

``

38

`+

`

``

39

`+

`

``

40

`+

`

``

41

`+

`

``

42

`+

`

``

43

`+

`

``

44

`+

`

``

45

+

``

46

`+

`

``

47

`+

`

``

48

`+

`

``

49

`+

`

``

50

`+

`

``

51

`+

`

``

52

`+

`

``

53

`+

`

``

54

`+

`

``

55

`+

`

``

56

`+

`

``

57

`+

modalReturnCode = [NSApp runModalForWindow:panel];

`

``

58

`+

`

``

59

`+

`

``

60

`+

`

``

61

`+

`

``

62

`+

`

``

63

`+

`

``

64

`+

`

``

65

`+

`

``

66

`+

`

``

67

`+

`

``

68

`+

`

``

69

`+

`

``

70

`+

`

``

71

`+

[NSApp tkFilePanelDidEnd:panel

`

``

72

`+

`

``

73

`+

`

``

74

`+

`

``

75

`+

`

``

76

`+

`

``

77

`+

`

``

78

`+

modalReturnCode = [panel runModal];

`

``

79

`+

} else {

`

``

80

`+

`

``

81

`+

modalReturnCode = [panel runModal];

`

``

82

`+

[NSApp tkFilePanelDidEnd:panel

`

``

83

`+

`

``

84

`+

`

``

85

`+

`

``

86

`+

`

``

87

`+

`

``

88

`+

}

`

``

89

`+

`

``

90

`+

`

``

91

`+

`

``

92

`+

`

``

93

`+

`

``

94

`+

}

`

``

95

`+

return callbackInfo->cmdObj ? modalOther : modalReturnCode;

`

``

96

`+

}

`

``

97

`+

@@ -422,7 +414,7 @@

`

``

98

`+

Tcl_Obj const objv[]) / Argument objects. */

`

``

99

`+

{

`

``

100

`+

int result = TCL_ERROR;

`

``

101

`+

`

``

102

`+

`

``

103

`+

const char *title = NULL;

`

``

104

`+

int i;

`

``

105

`+

NSColor *color = nil, *initialColor = nil;

`

``

106

`+

@@ -677,7 +669,7 @@

`

``

107

`+

int objc, /* Number of arguments. */

`

``

108

`+

Tcl_Obj const objv[]) / Argument objects. */

`

``

109

`+

{

`

``

110

`+

`

``

111

`+

`

``

112

`+

char *str;

`

``

113

`+

int i, result = TCL_ERROR, haveParentOption = 0;

`

``

114

`+

int index, len, multiple = 0;

`

``

115

`+

@@ -1679,10 +1671,10 @@

`

``

116

`+

if (!fontchooserInterp) {

`

``

117

`+

return;

`

``

118

`+

}

`

``

119

`+

`

``

120

`+

`

``

121

`+

switch (kind) {

`

``

122

`+

case FontchooserClosed:

`

``

123

`+

`

``

124

`+

`

``

125

`+

TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility", NULL);

`

``

126

`+

fontchooserInterp = NULL;

`

``

127

`+

}

`

``

128

`+

@@ -1738,7 +1730,7 @@

`

``

129

+

``

130

`+

switch(optionIndex) {

`

``

131

`+

case FontchooserParent:

`

``

132

`+

`

``

133

`+

`

``

134

`+

resObj = Tcl_NewStringObj(

`

``

135

`+

((TkWindow *)fcdPtr->parent)->pathName, -1);

`

``

136

`+

} else {

`

``

137

`+

@@ -1801,7 +1793,7 @@

`

``

138

`+

Tcl_Obj *const objv[])

`

``

139

`+

{

`

``

140

`+

Tk_Window tkwin = (Tk_Window)clientData;

`

``

141

`+

`

``

142

`+

`

``

143

`+

NULL);

`

``

144

`+

int i, r = TCL_OK;

`

``

145

+

``

146

`+

@@ -1858,7 +1850,7 @@

`

``

147

`+

Tk_Window parent = Tk_NameToWindow(interp,

`

``

148

`+

Tcl_GetString(objv[i+1]), tkwin);

`

``

149

+

``

150

`+

`

``

151

`+

`

``

152

`+

return TCL_ERROR;

`

``

153

`+

}

`

``

154

`+

if (fcdPtr->parent) {

`

``

155

`+

@@ -1885,7 +1877,7 @@

`

``

156

`+

fcdPtr->titleObj = NULL;

`

``

157

`+

}

`

``

158

`+

break;

`

``

159

`+

`

``

160

`+

`

``

161

`+

Tcl_GetStringFromObj(objv[i+1], &len);

`

``

162

`+

if (len) {

`

``

163

`+

Tk_Font f = Tk_AllocFontFromObj(interp, tkwin, objv[i+1]);

`

``

164

`+

@@ -1919,6 +1911,7 @@

`

``

165

`+

"TkFontchooserFontChanged", NULL);

`

``

166

`+

}

`

``

167

`+

break;

`

``

168

`+

`

``

169

`+

case FontchooserCmd:

`

``

170

`+

if (fcdPtr->cmdObj) {

`

``

171

`+

Tcl_DecrRefCount(fcdPtr->cmdObj);

`

``

172

`+

@@ -1964,10 +1957,10 @@

`

``

173

`+

TCL_UNUSED(int),

`

``

174

`+

TCL_UNUSED(Tcl_Obj *const *))

`

``

175

`+

{

`

``

176

`+

`

``

177

`+

`

``

178

`+

NULL);

`

``

179

+

``

180

`+

`

``

181

`+

`

``

182

`+

fcdPtr->parent = (Tk_Window)clientData;

`

``

183

`+

Tk_CreateEventHandler(fcdPtr->parent, StructureNotifyMask,

`

``

184

`+

FontchooserParentEventHandler, fcdPtr);

`

``

185

`+

@@ -2042,7 +2035,7 @@

`

``

186

`+

ClientData clientData,

`

``

187

`+

XEvent *eventPtr)

`

``

188

`+

{

`

``

189

`+

`

``

190

`+

`

``

191

+

``

192

`+

if (eventPtr->type == DestroyNotify) {

`

``

193

`+

Tk_DeleteEventHandler(fcdPtr->parent, StructureNotifyMask,

`

``

194

`+

@@ -2074,7 +2067,7 @@

`

``

195

`+

ClientData clientData,

`

``

196

`+

Tcl_Interp *interp)

`

``

197

`+

{

`

``

198

`+

`

``

199

`+

`

``

200

+

``

201

`+

if (fcdPtr->titleObj) {

`

``

202

`+

Tcl_DecrRefCount(fcdPtr->titleObj);

`