SonyWWS / ATF

Authoring Tools Framework (ATF) is a set of C#/.NET components for making tools on Windows. ATF has been in continuous development in Sony Computer Entertainment's (SCE) Worldwide Studios central tools group since early 2005. ATF has been used by most SCE first party studios to make many custom tools such as Naughty Dog’s level editor and shader editor for The Last of Us, Guerrilla Games’ sequence editor for Killzone games (including the Killzone: Shadow Fall PS4 launch title), an animation blending tool at Santa Monica Studio, a level editor at Bend Studio, a visual state machine editor for Quantic Dream, sound editing tools, and many others.
Apache License 2.0
1.89k stars 262 forks source link

ControlHostService Closing ignores CancelEventArgs.Cancel #14

Closed ColinCren closed 9 years ago

ColinCren commented 10 years ago

I've registered on the IMainWindow Closing Event to throw up a prompt if a document is dirty when the app closes. If I do want to throw up the prompt, I want to cancel the close event and call close myself when I'm done with the save.

However it seems ControlHostService mainForm_Closing sets e.Cancel to the result of !Close overwriting the value I set. I think ln718 needs to be e.Cancel = e.Cancel || !Close();

Does that sound right?

ColinCren commented 9 years ago

Also when the mainform does not cancel and an intervening operation closes the mainform, it seems to interrupt the layout saving causing an exception in subsequent loads. My suggested change in the original post fixes that as well.

Ron2 commented 9 years ago

Good point, Colin. I'll check in your change shortly. Thanks for the good suggestion.

I assume you made sure that your event handler gets the Closing event before ControlHostService. I wish that the ordering of the listeners didn't matter, but there's no way around that restriction given the IControlHostClient interface. (There's no "CanClose" method.)

ColinCren commented 9 years ago

In my use case it is.