Bug 394466 - "Call XCloseDisplay before exit and exec" [p=karlt r=roc r=bsmedberg a1.9=bzbarsky]

This commit is contained in:
reed@reedloden.com 2007-09-04 14:10:40 -07:00
parent 48d7fbcda6
commit cb57d0d70e

View File

@ -2680,9 +2680,34 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
if (CheckArg("install"))
gdk_rgb_set_install(TRUE);
// Initialize GTK here for splash
gtk_init(&gArgc, &gArgv);
// Initialize GTK here for splash.
// Open the display ourselves instead of using gtk_init, so that we can
// close it without fear that one day gtk might clean up the display it
// opens.
if (!gtk_parse_args(&gArgc, &gArgv))
return 1;
GdkDisplay* display = nsnull;
{
// display_name is owned by gdk.
const char *display_name = gdk_get_display_arg_name();
if (!display_name) {
display_name = PR_GetEnv("DISPLAY");
if (!display_name) {
PR_fprintf(PR_STDERR, "Error: no display specified\n");
return 1;
}
}
display = gdk_display_open(display_name);
if (!display) {
PR_fprintf(PR_STDERR, "Error: cannot open display: %s\n", display_name);
return 1;
}
}
gdk_display_manager_set_default_display (gdk_display_manager_get (),
display);
// g_set_application_name () is only defined in glib2.2 and higher.
_g_set_application_name_fn _g_set_application_name =
(_g_set_application_name_fn)FindFunction("g_set_application_name");
@ -3142,6 +3167,8 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
}
#endif
// XXXkt s/MOZ_TOOLKIT_GTK2/MOZ_WIDGET_GTK2/?
// but the hidden window has been destroyed so toolkit is NULL anyway.
#if defined(HAVE_DESKTOP_STARTUP_ID) && defined(MOZ_TOOLKIT_GTK2)
nsGTKToolkit* toolkit = GetGTKToolkit();
if (toolkit) {
@ -3157,6 +3184,10 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
}
#endif
#ifdef MOZ_WIDGET_GTK2
gdk_display_close(display);
#endif
rv = LaunchChild(nativeApp, appInitiatedRestart, upgraded ? -1 : 0);
#ifdef MOZ_CRASHREPORTER
@ -3166,6 +3197,12 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
return rv == NS_ERROR_LAUNCHED_CHILD_PROCESS ? 0 : 1;
}
#ifdef MOZ_WIDGET_GTK2
// gdk_display_close also calls gdk_display_manager_set_default_display
// appropriately when necessary.
gdk_display_close(display);
#endif
}
#ifdef MOZ_CRASHREPORTER