Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2240533

Browse files
committed
Issue #22068: Don't create self reference cycles in idlelib.ConfigDialog.
1 parent 74596a8 commit 2240533

1 file changed

Lines changed: 38 additions & 29 deletions

File tree

Lib/idlelib/configDialog.py

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(self, parent, title, _htest=False, _utest=False):
3030
_utest - bool, don't wait_window when running unittest
3131
"""
3232
Toplevel.__init__(self, parent)
33+
self.parent = parent
3334
self.wm_withdraw()
3435

3536
self.configure(borderwidth=5)
@@ -61,7 +62,6 @@ def __init__(self, parent, title, _htest=False, _utest=False):
6162
self.transient(parent)
6263
self.grab_set()
6364
self.protocol("WM_DELETE_WINDOW", self.Cancel)
64-
self.parent = parent
6565
self.tabPages.focus_set()
6666
#key bindings for this dialog
6767
#self.bind('<Escape>',self.Cancel) #dismiss dialog, no save
@@ -112,12 +112,13 @@ def CreateWidgets(self):
112112
self.tabPages.pack(side=TOP,expand=TRUE,fill=BOTH)
113113

114114
def CreatePageFontTab(self):
115-
#tkVars
116-
self.fontSize=StringVar(self)
117-
self.fontBold=BooleanVar(self)
118-
self.fontName=StringVar(self)
119-
self.spaceNum=IntVar(self)
120-
self.editFont=tkFont.Font(self,('courier',10,'normal'))
115+
parent = self.parent
116+
self.fontSize = StringVar(parent)
117+
self.fontBold = BooleanVar(parent)
118+
self.fontName = StringVar(parent)
119+
self.spaceNum = IntVar(parent)
120+
self.editFont = tkFont.Font(parent,('courier',10,'normal'))
121+
121122
##widget creation
122123
#body frame
123124
frame=self.tabPages.pages['Fonts/Tabs'].frame
@@ -153,6 +154,7 @@ def CreatePageFontTab(self):
153154
self.scaleSpaceNum=Scale(frameIndentSize, variable=self.spaceNum,
154155
orient='horizontal',
155156
tickinterval=2, from_=2, to=16)
157+
156158
#widget packing
157159
#body
158160
frameFont.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH)
@@ -175,13 +177,15 @@ def CreatePageFontTab(self):
175177
return frame
176178

177179
def CreatePageHighlight(self):
178-
self.builtinTheme=StringVar(self)
179-
self.customTheme=StringVar(self)
180-
self.fgHilite=BooleanVar(self)
181-
self.colour=StringVar(self)
182-
self.fontName=StringVar(self)
183-
self.themeIsBuiltin=BooleanVar(self)
184-
self.highlightTarget=StringVar(self)
180+
parent = self.parent
181+
self.builtinTheme = StringVar(parent)
182+
self.customTheme = StringVar(parent)
183+
self.fgHilite = BooleanVar(parent)
184+
self.colour = StringVar(parent)
185+
self.fontName = StringVar(parent)
186+
self.themeIsBuiltin = BooleanVar(parent)
187+
self.highlightTarget = StringVar(parent)
188+
185189
##widget creation
186190
#body frame
187191
frame=self.tabPages.pages['Highlighting'].frame
@@ -240,6 +244,7 @@ def CreatePageHighlight(self):
240244
self.customTheme,None,command=None)
241245
self.buttonDeleteCustomTheme=Button(frameTheme,text='Delete Custom Theme',
242246
command=self.DeleteCustomTheme)
247+
243248
##widget packing
244249
#body
245250
frameCustom.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH)
@@ -264,12 +269,13 @@ def CreatePageHighlight(self):
264269
return frame
265270

266271
def CreatePageKeys(self):
267-
#tkVars
268-
self.bindingTarget=StringVar(self)
269-
self.builtinKeys=StringVar(self)
270-
self.customKeys=StringVar(self)
271-
self.keysAreBuiltin=BooleanVar(self)
272-
self.keyBinding=StringVar(self)
272+
parent = self.parent
273+
self.bindingTarget = StringVar(parent)
274+
self.builtinKeys = StringVar(parent)
275+
self.customKeys = StringVar(parent)
276+
self.keysAreBuiltin = BooleanVar(parent)
277+
self.keyBinding = StringVar(parent)
278+
273279
##widget creation
274280
#body frame
275281
frame=self.tabPages.pages['Keys'].frame
@@ -307,6 +313,7 @@ def CreatePageKeys(self):
307313
command=self.DeleteCustomKeys)
308314
buttonSaveCustomKeys=Button(frames[1],
309315
text='Save as New Custom Key Set',command=self.SaveAsNewKeySet)
316+
310317
##widget packing
311318
#body
312319
frameCustom.pack(side=BOTTOM,padx=5,pady=5,expand=TRUE,fill=BOTH)
@@ -333,15 +340,16 @@ def CreatePageKeys(self):
333340
return frame
334341

335342
def CreatePageGeneral(self):
336-
#tkVars
337-
self.winWidth=StringVar(self)
338-
self.winHeight=StringVar(self)
339-
self.paraWidth=StringVar(self)
340-
self.startupEdit=IntVar(self)
341-
self.autoSave=IntVar(self)
342-
self.encoding=StringVar(self)
343-
self.userHelpBrowser=BooleanVar(self)
344-
self.helpBrowser=StringVar(self)
343+
parent = self.parent
344+
self.winWidth = StringVar(parent)
345+
self.winHeight = StringVar(parent)
346+
self.paraWidth = StringVar(parent)
347+
self.startupEdit = IntVar(parent)
348+
self.autoSave = IntVar(parent)
349+
self.encoding = StringVar(parent)
350+
self.userHelpBrowser = BooleanVar(parent)
351+
self.helpBrowser = StringVar(parent)
352+
345353
#widget creation
346354
#body
347355
frame=self.tabPages.pages['General'].frame
@@ -395,6 +403,7 @@ def CreatePageGeneral(self):
395403
width=8,command=self.HelpListItemAdd)
396404
self.buttonHelpListRemove=Button(frameHelpListButtons,text='Remove',
397405
state=DISABLED,width=8,command=self.HelpListItemRemove)
406+
398407
#widget packing
399408
#body
400409
frameRun.pack(side=TOP,padx=5,pady=5,fill=X)

0 commit comments

Comments
 (0)