提交 33af823a 编写于 作者: S serb

8185325: Improve GTK initialization

Reviewed-by: azvegint, rhalade, mschoene
上级 cd9b3518
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -843,46 +843,41 @@ gboolean gtk2_load(JNIEnv *env) ...@@ -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"); gtk_modules_env = getenv ("GTK_MODULES");
if ((gtk_modules_env && strstr(gtk_modules_env, "atk-bridge")) ||
if (gtk_modules_env && strstr (gtk_modules_env, "atk-bridge") || (gtk_modules_env && strstr(gtk_modules_env, "gail"))) {
gtk_modules_env && strstr (gtk_modules_env, "gail")) /* careful, strtok modifies its args */
{ gchar *tmp_env = strdup(gtk_modules_env);
/* the new env will be smaller than the old one */ if (tmp_env) {
gchar *s, *new_env = SAFE_SIZE_STRUCT_ALLOC(malloc, /* the new env will be smaller than the old one */
sizeof(ENV_PREFIX), 1, strlen (gtk_modules_env)); gchar *s, *new_env = SAFE_SIZE_STRUCT_ALLOC(malloc,
sizeof(ENV_PREFIX), 1, strlen (gtk_modules_env));
if (new_env != NULL )
{ if (new_env) {
/* careful, strtok modifies its args */ strcpy(new_env, ENV_PREFIX);
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);
/* strip out 'atk-bridge' and 'gail' */ gchar *tmp_ptr = NULL;
size_t PREFIX_LENGTH = strlen(ENV_PREFIX); for (s = strtok_r(tmp_env, ":", &tmp_ptr); s;
while (s = strtok(tmp_env, ":")) s = strtok_r(NULL, ":", &tmp_ptr)) {
{ if ((!strstr(s, "atk-bridge")) && (!strstr(s, "gail"))) {
if ((!strstr (s, "atk-bridge")) && (!strstr (s, "gail"))) if (strlen(new_env) > PREFIX_LENGTH) {
{ new_env = strcat(new_env, ":");
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) if (putenv(new_env) != 0) {
{ /* no free() on success, putenv() doesn't copy string */
free (tmp_env); free(new_env);
tmp_env = NULL; /* next call to strtok arg1==NULL */
} }
} }
putenv (new_env); free(tmp_env);
free (new_env);
free (tmp_env);
} }
} }
/* /*
* GTK should be initialized with gtk_init_check() before use. * 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.
先完成此消息的编辑!
想要评论请 注册