Ticket #15883 (closed defect: fixed)
wxDocument::OnCreate returning false no longer deletes document or removes it from the doc manager
|Reported by:||snowleopard2||Owned by:||vadz|
In 2.9.4 and before, if wxDocument::OnCreate returned false, then wxDocTemplate::InitDocument would call DeleteAllViews on the document, which in turn would delete it and remove it from the doc manager. This was done via a scope guard that would call DeleteAllViews if OnCreate returned false.
However, after 2.9.4 this scope guard in wxDocTemplate::InitDocument was removed and now DeleteAllViews is only called if OnCreate throws an exception (handled in a catch block). It's good that it handles exceptions now (didn't before), but if OnCreate returns false then the document is never destroyed and it this half-created document remains lingering in the doc manager's document collection.
I'm thinking wxDocTemplate::InitDocument should check OnCreate's return first and call DeleteAllViews if false before returning OnCreate's return value.