Problem: 1615465

Title: (TView) ~TView() Should Test gApplication != NULL

Received: Dec 24 1996 2:23PM


I have a few disembodied Views (uses as prototypes for creating others) that are managed by Behaviors attached to the Application. Unfortunately, ~TView() dereferences gApplication without testing it first. This causes a horrible crash when the Application is Quit, because gApplication has already been set to NULL before deleting the Application which preceeds deleting its behaviors. Please make the following change to correct it: Old:
============================================================
  while (fSubView)
    fSubView->Free();
  this->InvalidateFocus();
  gApplication->InvalidateMouseRegions();    // Must re-calc cursor and help rgn.
  if (this == gApplication->GetTarget())     // Fixup the target chain
    gApplication->SetTarget(gApplication);
(more)
============================================================
Proposed:
============================================================
  while (fSubView)
    fSubView->Free();
  this->InvalidateFocus();
  if(gApplication)
    gApplication->InvalidateMouseRegions();               // Must re-calc cursor and help rgn.
  if (gApplication && this == gApplication->GetTarget())  // Fixup the target chain
    gApplication->SetTarget(gApplication);
(more)
============================================================

Fix:

Fixed.