Open koendehondt opened 6 months ago
I extracted
announceWillClose
| announcement |
announcement := WindowClosed new
window: self;
yourself.
self announce: announcement.
self currentWorld announcer announce: announcement
deleteDiscardingChanges
| thisWorld announcement |
self removePaneSplitters. "in case we add some panes and reopen!"
thisWorld := self world.
self isFlexed
ifTrue: [ owner delete ]
ifFalse: [ super delete ].
model
ifNotNil: [ model
windowIsClosing;
releaseActionMap ].
model := nil.
SystemWindow noteTopWindowIn: thisWorld.
self announceWillClose
Now this is not working because the the SpDialogPresenter
calls SpDialogWindowMorph
which is a subclass of WindowMorph
and not SpWindow
I need to discuss this, I am not sure we need deleteDiscardingChanges (and even delete is not recommended in spec, there is a reason why is on private method). For me this is a bug on the closeBoxHit method, that needs to be override in SpWindow to fix the problem, other than make a pump up of a specific functionality/problem of the morphic backend.
Ok fine by me. We struggled a lot on this bug and discussed also with @tesonep
@estebanlm This issue cannot be closed. The original issue is not fixed, as you can see in this video:
https://github.com/user-attachments/assets/a679a91d-2078-4068-bf47-4c1989edc2d0
Context: Pharo 12.
Consider this code:
Be aware that a
SpWindowWillClose
announcement has a default of allowing a window to close (seeSpWindowWillClose>>#initialize
). That is why the code above does not sendannouncement allowClose
.Here is the reason:
The method
closeBoxHit
sendsclose
:close
sends the announcement:That will trigger the
whenWillCloseDo:
block in the code snippet.SpWindow>>close
does a super send, becauseself announceWillClose
evaluates totrue
(the user clicked "Yes").The method in the superclass is:
and
delete
is:It does super send on the last line:
The last line sends
deleteDiscardingChanges
:This method announces the window close again, as
SpWindow>>close
already did. That results in opening the confirmation dialog again.