mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Change the way that application shutdown works in order to support JavaScript 'onbeforeunload' handling (issue #853). See comments in cef_life_span_handler.h for a detailed description of the new shutdown process.
- Fix a crash on Linux during window destruction (issue #681). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1149 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -24,12 +24,31 @@ char szWorkingDir[512]; // The current working directory
|
||||
// The global ClientHandler reference.
|
||||
extern CefRefPtr<ClientHandler> g_handler;
|
||||
|
||||
void destroy(void) {
|
||||
CefQuitMessageLoop();
|
||||
void destroy(GtkWidget* widget, gpointer data) {
|
||||
// Quitting CEF is handled in ClientHandler::OnBeforeClose().
|
||||
}
|
||||
|
||||
gboolean delete_event(GtkWidget* widget, GdkEvent* event,
|
||||
GtkWindow* window) {
|
||||
if (g_handler.get() && !g_handler->IsClosing()) {
|
||||
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
||||
if (browser.get()) {
|
||||
// Notify the browser window that we would like to close it. This
|
||||
// will result in a call to ClientHandler::DoClose() if the
|
||||
// JavaScript 'onbeforeunload' event handler allows it.
|
||||
browser->GetHost()->CloseBrowser(false);
|
||||
|
||||
// Allow the close.
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Cancel the close.
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void TerminationSignalHandler(int signatl) {
|
||||
destroy();
|
||||
AppQuitMessageLoop();
|
||||
}
|
||||
|
||||
// Callback for Debug > Get Source... menu item.
|
||||
@ -404,10 +423,10 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
|
||||
|
||||
g_signal_connect(G_OBJECT(window), "destroy",
|
||||
G_CALLBACK(gtk_widget_destroyed), &window);
|
||||
g_signal_connect(G_OBJECT(window), "destroy",
|
||||
G_CALLBACK(destroy), NULL);
|
||||
g_signal_connect(G_OBJECT(window), "delete_event",
|
||||
G_CALLBACK(delete_event), window);
|
||||
|
||||
// Create the handler.
|
||||
g_handler = new ClientHandler();
|
||||
@ -444,4 +463,8 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
std::string AppGetWorkingDirectory() {
|
||||
return szWorkingDir;
|
||||
}
|
||||
}
|
||||
|
||||
void AppQuitMessageLoop() {
|
||||
CefQuitMessageLoop();
|
||||
}
|
||||
|
Reference in New Issue
Block a user