Atom will auto-update on close if a newer version is on Speakeasy

The first call to terminate is canceled so that every window can be 
closed. On AtomCefClient the OnBeforeClose method is called when a
browser is finished closing. Once all windows have finished closing, AtomCefClient calls terminate again, which will terminate the 
application.

Closes #527
This commit is contained in:
probablycorey
2013-05-01 13:52:56 -07:00
parent 8f03ff2952
commit 850ecb23df
4 changed files with 19 additions and 5 deletions

View File

@@ -278,12 +278,21 @@
}
}
// The first call to terminate is canceled so that every window can be closed.
// On AtomCefClient the OnBeforeClose method is called when a browser is
// finished closing. Once all windows have finished closing, AtomCefClient calls
// terminate again, which will terminate the application.
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
for (NSWindow *window in [self windows]) {
[window performClose:self];
if (self.windows.count > 0) {
for (NSWindow *window in self.windows) {
[window performClose:self];
}
return NSTerminateCancel;
}
else {
CefQuitMessageLoop();
return NSTerminateNow;
}
return NSTerminateCancel;
}
# pragma mark CefAppProtocol

View File

@@ -174,7 +174,7 @@ void AtomCefClient::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
m_Browser = NULL;
numberOfOpenBrowsers--;
if (numberOfOpenBrowsers == 0) {
CefQuitMessageLoop();
Terminate();
}
}

View File

@@ -127,6 +127,7 @@ class AtomCefClient : public CefClient,
void ShowSaveDialog(int replyId, CefRefPtr<CefBrowser> browser);
CefRefPtr<CefListValue> CreateReplyDescriptor(int replyId, int callbackIndex);
void Exit(int status);
void Terminate();
void Log(const char *message);
void Show(CefRefPtr<CefBrowser> browser);
void ToggleFullScreen(CefRefPtr<CefBrowser> browser);

View File

@@ -159,6 +159,10 @@ void AtomCefClient::Exit(int status) {
exit(status);
}
void AtomCefClient::Terminate() {
[NSApp terminate:NSApp];
}
void AtomCefClient::Log(const char *message) {
NSLog(@"%s", message);
}