@@ -76,6 +76,7 @@ protected override void Dispose( bool disposing )
7676 if ( disposing )
7777 {
7878 Subscriber . Unsubscribe ( EventConstants . DeleteRecord , DeleteRecord ) ;
79+ Subscriber . Unsubscribe ( EventConstants . ConsideringClosing , ConsideringClosing ) ;
7980
8081 if ( components != null )
8182 {
@@ -104,6 +105,7 @@ public override void Init(XmlNode nodeSpec, int hvoRoot, int fakeFlid,
104105 base . Init ( nodeSpec , hvoRoot , fakeFlid , cache , mediator , bv ) ;
105106
106107 Subscriber . Subscribe ( EventConstants . DeleteRecord , DeleteRecord ) ;
108+ Subscriber . Subscribe ( EventConstants . ConsideringClosing , ConsideringClosing ) ;
107109 }
108110
109111 #endregion Construction, initialization, and disposal.
@@ -167,17 +169,22 @@ public override void SetSelectedRowHighlighting()
167169 #region XCore message handlers
168170
169171 /// <summary>
170- /// This name is magic for an xCoreColleague that is active at the time when an xWindow is being closed.
171- /// If some active colleague implements this method, it gets a chance to do something special as the
172- /// xWindow closes (and can veto the close, though we aren't really using that here).
172+ /// Cleanup any pending edits before a potential xWindow close.
173173 /// </summary>
174- /// <returns></returns>
175- public bool OnConsideringClosing ( object sender , CancelEventArgs arg )
174+ private void ConsideringClosing ( object obj )
176175 {
177176 CheckDisposed ( ) ;
178-
179- arg . Cancel = CleanupPendingEdits ( ) ;
180- return arg . Cancel ; // if we want to cancel, others don't need to be asked.
177+ if ( ! ( obj is CancelEventArgs arg ) )
178+ {
179+ Debug . Assert ( false , "Received unexpected object type." ) ;
180+ return ;
181+ }
182+ // Return if the close has already been canceled by another Subscriber.
183+ if ( arg . Cancel )
184+ {
185+ return ;
186+ }
187+ CleanupPendingEdits ( ) ;
181188 }
182189
183190 /// <summary>
@@ -288,10 +295,8 @@ private void SetSelection()
288295 /// <summary>
289296 /// Cleanup any pending edits.
290297 /// </summary>
291- /// <returns>True to cancel the window closing, otherwise false.</returns>
292- private bool CleanupPendingEdits ( )
298+ private void CleanupPendingEdits ( )
293299 {
294- bool cancelClose = false ;
295300 ITsString [ ] rgtss ;
296301 if ( CanGotoNextRow ( out rgtss ) )
297302 {
@@ -308,8 +313,6 @@ private bool CleanupPendingEdits()
308313 CreateObjectFromEntryRow ( rgtss , false ) ;
309314 }
310315 DoMerges ( ) ;
311-
312- return cancelClose ;
313316 }
314317 /// <summary>
315318 /// Check whether we have enough data entered in this row to go on to create another row.
0 commit comments