@@ -11,17 +11,18 @@ static Function IgorBeforeQuitHook(unsavedExp, unsavedNotebooks, unsavedProcedur
1111
1212 string expName
1313
14- debugprint ( "called" )
14+ debugPrint ( "called" )
15+ debugPrint ( "unsavedExp: " + num2str ( unsavedExp))
1516
16- preparePanelClose ()
17- markAsUnInitialized ()
17+ BeforePanelClose ()
18+ DoWindow / K CodeBrowser
19+ AfterPanelClose ()
1820
1921 if ( unsavedExp || unsavedNotebooks || unsavedProcedures)
2022 return 0
2123 endif
2224
2325 expName = IgorInfo ( 1 )
24-
2526 if ( ! cmpstr ( expName, "Untitled" ))
2627 return 0
2728 endif
4041static Function IgorBeforeNewHook ( igorApplicationNameStr)
4142 string igorApplicationNameStr
4243
43- preparePanelClose ()
44+ debugPrint ( "called" )
45+ BeforePanelClose ()
46+
4447 return 0
4548End
4649
@@ -66,38 +69,52 @@ Function initializePanel()
6669 setGlobalStr ( "search" , "" )
6770End
6871
69- // Prepare for panel closing, must be called before the panel is killed or the experiment closed
70- Function preparePanelClose ()
71-
72+ // Prepare for panel closing.
73+ //
74+ // note: Must be called before the panel is killed or the experiment is closed.
75+ Function BeforePanelClose ()
7276 SetIgorHook / K AfterCompiledHook= updatePanel
73- debugPrint ( "AfterCompiledHook: " + S_info)
77+ if ( strlen ( S_info) > 0 )
78+ debugPrint ( "registered hooks with hookType=AfterCompiledHook: " + S_info)
79+ else
80+ debugPrint ( "all hookType=AfterCompiledHook deleted" )
81+ endif
82+ End
83+
84+ // Clean up after closing panel
85+ //
86+ // note: Must be called after the panel was closed
87+ Function AfterPanelClose ()
88+ variable cleanOnExit
7489
7590 if ( ! existsPanel ())
7691 return 0
7792 endif
7893
79- // save panel coordinates to disk
80- STRUCT CodeBrowserPrefs prefs
81- FillPackagePrefsStruct ( prefs)
82- SavePackagePrefsToDisk ( prefs)
83-
84- // reset global gui variables
85- searchReset ()
86-
87- // delete CodeBrowser related data
88- if ( prefs. configCleanOnExit)
89- // storage data will not be saved in experiment
90- saveResetStorage ()
91- killGlobalVar ( "cleanOnExit" )
92- killGlobalVar ( "debuggingEnabled" )
94+ cleanOnExit = !! getGlobalVar ( "cleanOnExit" )
95+ QuitPackagePrefs ()
96+ if ( cleanOnExit)
97+ KillStorage ()
98+ KillPanelObjects ()
99+ DeletePKGfolder ()
93100 endif
94101End
95102
96- // if panel does not exist, delete panel-bound var/wave/dfr
97- Function killPanelRelatedObjects ()
103+ // Kill panel-bound variables and waves
104+ //
105+ // @see KillStorage
106+ //
107+ // note: if the waves and variables are still bound to a panel, this function
108+ // will only reset them.
109+ Function KillPanelObjects ()
98110 Wave /T decl = getDeclWave ()
99111 Wave /I line = getLineWave ()
100112
113+ // reset
114+ setGlobalStr ( "search" , "" )
115+ setGlobalVar ( "initialized" , 0 )
116+
117+ // kill
101118 KillWaves / Z decl, line
102119 killGlobalStr ( "search" )
103120 killGlobalVar ( "initialized" )
@@ -117,9 +134,8 @@ Function panelHook(s)
117134 markAsInitialized ()
118135 break
119136 case 2: // kill
120- preparePanelClose ()
121- killPanelRelatedObjects ()
122- DeletePKGfolder ()
137+ BeforePanelClose ()
138+ AfterPanelClose ()
123139 hookResult = 1
124140 break
125141 case 6: // resize
0 commit comments