diff --git a/AppKit/Platform/DOM/CPPlatform.j b/AppKit/Platform/DOM/CPPlatform.j index 9b287120d..a80f9b0e3 100644 --- a/AppKit/Platform/DOM/CPPlatform.j +++ b/AppKit/Platform/DOM/CPPlatform.j @@ -48,10 +48,13 @@ var screenNeedsInitialization = NO, document.documentElement.style.overflow = "hidden"; if ([CPPlatform isBrowser]) + { window.onunload = function() { + [self closeAllPlatformWindows]; [CPApp terminate:nil]; }; + } } + (BOOL)isBrowser @@ -138,4 +141,18 @@ var screenNeedsInitialization = NO, object:self]; } ++ (void)closeAllPlatformWindows +{ + var platformWindows = [CPPlatformWindow visiblePlatformWindows], + primaryPlatformWindow = [CPPlatformWindow primaryPlatformWindow], + platformWindowEnumerator = [platformWindows objectEnumerator], + platformWindow = nil; + + while ((platformWindow = [platformWindowEnumerator nextObject]) !== nil) + { + if (platformWindow != primaryPlatformWindow) + [platformWindow orderOut:self]; + } +} + @end