Skip to content

Commit 64977c4

Browse files
author
Matthias Kastner
committed
simplification: existsPanel()
DoWindow with followed V_Value checking was substituted by a more readable simplification.
1 parent 3c416ec commit 64977c4

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

procedures/CodeBrowser_gui.ipf

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ Function createPanel()
3737
STRUCT CodeBrowserPrefs prefs
3838
LoadPackagePrefsFromDisk(prefs)
3939

40-
DoWindow $panel
41-
if(V_flag != 0)
42-
DebugPrint("Panel Exists")
40+
if(existsPanel())
4341
DoWindow/F $panel
4442
return NaN
4543
endif
@@ -125,8 +123,7 @@ Function resizeToPackagePrefs()
125123
Variable prefsRight = prefs.panelCoords[2]
126124
Variable prefsBottom = prefs.panelCoords[3]
127125

128-
DoWindow $panel
129-
if(V_flag == 0)
126+
if(!existsPanel())
130127
createPanel()
131128
endif
132129
MoveWindow/W=$panel prefsLeft, prefsTop, prefsRight, prefsBottom
@@ -165,32 +162,36 @@ Function updatePanel()
165162
saveReParse()
166163
debugPrint("All Procedures were marked for parsing")
167164

168-
DoWindow $panel
169-
if(V_flag == 0)
165+
if(!existsPanel())
170166
return 0
171167
endif
172-
debugPrint("panel exists")
173168

174169
ControlUpdate/A/W=$panel
175170
updateListBoxHook()
176171

177172
return 0
178173
End
179174

180-
Function markAsUnInitialized()
181-
175+
Function existsPanel()
182176
DoWindow $panel
183177
if(V_flag == 0)
184178
return 0
185179
endif
180+
debugPrint("panel exists")
181+
return 1
182+
End
183+
184+
Function markAsUnInitialized()
185+
if(!existsPanel())
186+
return 0
187+
endif
186188

187189
SetWindow $panel, userdata($oneTimeInitUserData)=""
188190
End
189191

190192
Function markAsInitialized()
191193

192-
DoWindow $panel
193-
if(V_flag == 0)
194+
if(!existsPanel())
194195
return 0
195196
endif
196197

@@ -199,8 +200,7 @@ End
199200

200201
Function isInitialized()
201202

202-
DoWindow $panel
203-
if(V_flag == 0)
203+
if(!existsPanel())
204204
return 0
205205
endif
206206

procedures/CodeBrowser_hooks.ipf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ Function preparePanelClose()
7070
SetIgorHook/K AfterCompiledHook=updatePanel
7171
debugPrint("AfterCompiledHook: " + S_info)
7272

73-
DoWindow $GetPanel()
74-
if(V_flag == 0)
73+
if(!existsPanel())
7574
return 0
7675
endif
7776

procedures/CodeBrowser_preferences.ipf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ End
103103
Function FillPackagePrefsStruct(prefs)
104104
STRUCT CodeBrowserPrefs &prefs
105105

106-
DoWindow $GetPanel()
107-
if(V_flag == 0)
106+
if(!existsPanel())
108107
// Panel does not exist. Set prefs struct to default.
109108
DefaultPackagePrefsStruct(prefs)
110109
else

0 commit comments

Comments
 (0)