Mercurial > hg > openjdk > jdk6 > jdk
changeset 1758:2f33be2c6b6a
8185325: Improve GTK initialization
Reviewed-by: azvegint, rhalade, mschoene
author | serb |
---|---|
date | Tue, 03 Oct 2017 14:25:31 -0700 |
parents | e05b23750b9b |
children | 478885d1d686 |
files | src/solaris/native/sun/awt/gtk2_interface.c |
diffstat | 1 files changed, 26 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/src/solaris/native/sun/awt/gtk2_interface.c Thu Oct 22 15:43:25 2009 +0400 +++ b/src/solaris/native/sun/awt/gtk2_interface.c Tue Oct 03 14:25:31 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2007, 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 @@ -629,46 +629,41 @@ } /* - * 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"))) { + /* 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 (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); + if (new_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, ":"); + /* 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. *