changeset 203:5d98f1b8a6bb

Merge
author ant
date Thu, 27 Mar 2008 11:35:00 +0300
parents 4a6dd11fe9fc c58ca64469bb
children 6e2a17c648a4
files
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c	Wed Mar 26 17:38:26 2008 +0300
+++ b/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c	Thu Mar 27 11:35:00 2008 +0300
@@ -436,6 +436,7 @@
             break;
         }
     case PseudoColor: {
+            int availableColors;
             int numColors;
             int numComponents[3];
             unsigned long colorIndex[SPLASH_COLOR_MAP_SIZE];
@@ -444,9 +445,20 @@
             int depth = XDefaultDepthOfScreen(splash->screen);
             int scale = 65535 / MAX_COLOR_VALUE;
 
-            numColors = GetNumAvailableColors(splash->display, splash->screen,
+            availableColors = GetNumAvailableColors(splash->display, splash->screen,
                     splash->visual->map_entries);
-            numColors = quantizeColors(numColors, numComponents);
+            numColors = quantizeColors(availableColors, numComponents);
+            if (numColors > availableColors) {
+                // Could not allocate the color cells. Most probably
+                // the pool got exhausted. Disable the splash screen.
+                XCloseDisplay(splash->display);
+                splash->isVisible = -1;
+                splash->display = NULL;
+                splash->screen = NULL;
+                splash->visual = NULL;
+                fprintf(stderr, "Warning: unable to initialize the splashscreen. Not enough available color cells.\n");
+                return;
+            }
             splash->cmap = AllocColors(splash->display, splash->screen,
                     numColors, colorIndex);
             for (i = 0; i < numColors; i++) {