提交 c0539345 编写于 作者: S serb

8185325: Improve GTK initialization

Reviewed-by: azvegint, rhalade, mschoene
上级 5f7ce206
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -843,46 +843,41 @@ gboolean gtk2_load(JNIEnv *env)
}
/*
* Strip the AT-SPI GTK_MODULEs if present
* Strip the AT-SPI GTK_MODULES if present
*/
gtk_modules_env = getenv ("GTK_MODULES");
if (gtk_modules_env && strstr (gtk_modules_env, "atk-bridge") ||
gtk_modules_env && strstr (gtk_modules_env, "gail"))
{
/* the new env will be smaller than the old one */
gchar *s, *new_env = SAFE_SIZE_STRUCT_ALLOC(malloc,
sizeof(ENV_PREFIX), 1, strlen (gtk_modules_env));
if (new_env != NULL )
{
/* careful, strtok modifies its args */
gchar *tmp_env = strdup (gtk_modules_env);
strcpy(new_env, ENV_PREFIX);
/* strip out 'atk-bridge' and 'gail' */
size_t PREFIX_LENGTH = strlen(ENV_PREFIX);
while (s = strtok(tmp_env, ":"))
{
if ((!strstr (s, "atk-bridge")) && (!strstr (s, "gail")))
{
if (strlen (new_env) > PREFIX_LENGTH) {
new_env = strcat (new_env, ":");
if ((gtk_modules_env && strstr(gtk_modules_env, "atk-bridge")) ||
(gtk_modules_env && strstr(gtk_modules_env, "gail"))) {
/* careful, strtok modifies its args */
gchar *tmp_env = strdup(gtk_modules_env);
if (tmp_env) {
/* the new env will be smaller than the old one */
gchar *s, *new_env = SAFE_SIZE_STRUCT_ALLOC(malloc,
sizeof(ENV_PREFIX), 1, strlen (gtk_modules_env));
if (new_env) {
strcpy(new_env, ENV_PREFIX);
/* strip out 'atk-bridge' and 'gail' */
size_t PREFIX_LENGTH = strlen(ENV_PREFIX);
gchar *tmp_ptr = NULL;
for (s = strtok_r(tmp_env, ":", &tmp_ptr); s;
s = strtok_r(NULL, ":", &tmp_ptr)) {
if ((!strstr(s, "atk-bridge")) && (!strstr(s, "gail"))) {
if (strlen(new_env) > PREFIX_LENGTH) {
new_env = strcat(new_env, ":");
}
new_env = strcat(new_env, s);
}
new_env = strcat(new_env, s);
}
if (tmp_env)
{
free (tmp_env);
tmp_env = NULL; /* next call to strtok arg1==NULL */
if (putenv(new_env) != 0) {
/* no free() on success, putenv() doesn't copy string */
free(new_env);
}
}
putenv (new_env);
free (new_env);
free (tmp_env);
free(tmp_env);
}
}
/*
* GTK should be initialized with gtk_init_check() before use.
*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册