[EMAIL PROTECTED] wrote:

I still don't use fvwm-themes but I can confirm core dumps at least a
few times.  However only if the config file contains the gradients, if I
use FvwmConsole to dump in the colorsets I get same errors, and the
gradients are changed, but they are not really gradients, more random
color masks.  Also works the same if I use *FvwmTheme: Colorset.
Another patch that fixes my problems. It was due to running out of colors on 8bit while having ReadWriteColors turned on.

This patch also initializes monochrome pixmaps to have a gray background. It does three types for colorsets 0, 1 & 2 and then repeats for any more. These pixmaps correspond to the ones fvwm uses by default in mono for normal, focused and sticky windows. If modules are to use them the colorsets the modules use must be referred to by fvwm before the module starts e.g. put "Colorset 2" in the StartFunction before the modules are started.

This probably won't fix your problems, if it doesn't you should be able to get a core dump by starting fvwm with the -debug flag to get synchronous behaviour and then putting "abort();" in the error handler routine (fvwm.c line 1762).

Hope this helps,
Tim.

Index: libs/Colorset.c
===================================================================
RCS file: /u/phippst/share/cvsroot/fvwm/libs/Colorset.c,v
retrieving revision 1.1
diff -u -r1.1 Colorset.c
--- libs/Colorset.c     2002/04/18 10:47:18     1.1
+++ libs/Colorset.c     2002/04/19 13:56:35
@@ -50,21 +50,15 @@
   Colorset = (colorset_struct *)saferealloc((char *)Colorset,
                                            ++n * sizeof(colorset_struct));
 
-  /* zero out the new members */
-  memset(&Colorset[nColorsets], 0, (n - nColorsets) * sizeof(colorset_struct));
-
-  /* copy colorset 0 pixels into new members so that if undefined ones are
-   * referenced at least they don't give black on black */
-  if (n > 1)
-  {
+  /* zero out colorset 0
+     it's always defined so will be filled in during module startup */
+  if (n == 0)
+    memset(&Colorset[nColorsets], 0, (n - nColorsets) * 
sizeof(colorset_struct));
+  else
+    /* copy colorset 0 into new members so that if undefined ones are
+     * referenced at least they don't give black on black */
     for ( ; nColorsets < n; nColorsets++)
-    {
-      Colorset[nColorsets].fg = Colorset[0].fg;
-      Colorset[nColorsets].bg = Colorset[0].bg;
-      Colorset[nColorsets].hilite = Colorset[0].hilite;
-      Colorset[nColorsets].shadow = Colorset[0].shadow;
-    }
-  }
+      memcpy(&Colorset[nColorsets], Colorset, sizeof(colorset_struct));
 
   nColorsets = n;
 }
Index: fvwm/colorset.c
===================================================================
RCS file: /u/phippst/share/cvsroot/fvwm/fvwm/colorset.c,v
retrieving revision 1.3
diff -u -r1.3 colorset.c
--- fvwm/colorset.c     2002/04/19 10:27:23     1.3
+++ fvwm/colorset.c     2002/04/19 15:07:53
@@ -275,7 +275,7 @@
        Window win = Scr.SizeWindow;
        static GC gc = None, monoGC = None;
 
-       /* initialize statucs */
+       /* initialize statics */
        if (gc == None)
        {
                gc = fvwmlib_XCreateGC(dpy, win, 0, &xgcv);
@@ -283,67 +283,7 @@
        }
 
        /* make sure it exists and has sensible contents */
-       if (nColorsets <= n) {
-               Colorset = (colorset_struct *)saferealloc(
-                       (char *)Colorset, (n + 1) * sizeof(colorset_struct));
-               memset(
-                       &Colorset[nColorsets], 0,
-                       (n + 1 - nColorsets) * sizeof(colorset_struct));
-       }
-
-       /* initialize new colorsets to black on gray */
-       while (nColorsets <= n)
-       {
-               colorset_struct *ncs = &Colorset[nColorsets];
-
-               have_pixels_changed = True;
-               if (privateCells && XAllocColorCells(
-                       /* grab four writeable cells */
-                       dpy, Pcmap, False, NULL, 0, &(ncs->fg), 4))
-               {
-                       XColor *colorp;
-
-                       /* set the fg color */
-                       MyXParseColor(black, &color);
-                       color.pixel = ncs->fg;
-                       XStoreColor(dpy, Pcmap, &color);
-                       /* set the bg */
-                       MyXParseColor(gray, &color);
-                       color.pixel = ncs->bg;
-                       XStoreColor(dpy, Pcmap, &color);
-                       /* calculate and set the hilite */
-                       colorp = GetHiliteColor(ncs->bg);
-                       colorp->pixel = ncs->hilite;
-                       XStoreColor(dpy, Pcmap, colorp);
-                       /* calculate and set the shadow */
-                       colorp = GetShadowColor(ncs->bg);
-                       colorp->pixel = ncs->shadow;
-                       XStoreColor(dpy, Pcmap, colorp);
-               }
-               else
-               {
-                       /* grab four shareable colors */
-                       if (Pdepth < 2) {
-                               /* monochrome monitors get black on white */
-                               /* FIXME: with a gray pixmap background */
-                               ncs->fg = GetColor(black);
-                               ncs->bg = GetColor(white);
-                               ncs->hilite = GetColor(white);
-                               ncs->shadow = GetColor(black);
-                       }
-                       else
-                       {
-                               ncs->fg = GetColor(black);
-                               ncs->bg = GetColor(gray);
-                               ncs->hilite = GetHilite(ncs->bg);
-                               ncs->shadow = GetShadow(ncs->bg);
-                       }
-                       /* set flags for fg contrast, bg average */
-                       /* in case just a pixmap is given */
-                       ncs->color_flags = FG_CONTRAST | BG_AVERAGE;
-               }
-               nColorsets++;
-       }
+       alloc_colorset(n);
 
        cs = &Colorset[n];
 
@@ -936,12 +876,6 @@
                free(hi);
        if (sh)
                free(sh);
-
-       /* if privateCells are not being used and XAllocColor has been used
-        * we are stuck in sharedCells behaviour forever */
-       /* have_pixels_changed will be set if a new colorset has been made */
-       if (!privateCells && have_pixels_changed)
-               sharedCells = True;
 }
 
 /*****************************************************************************
@@ -954,10 +888,81 @@
        /* do nothing if it already exists */
        if (n < nColorsets)
                return;
+       else {
+               Colorset = (colorset_struct *)saferealloc(
+                       (char *)Colorset, (n + 1) * sizeof(colorset_struct));
+               memset(
+                       &Colorset[nColorsets], 0,
+                       (n + 1 - nColorsets) * sizeof(colorset_struct));
+       }
 
-       /* parse_colorset resizes the array if necessary
-        * so just use it to get a sensible default */
-       parse_colorset(n, "");
+       /* initialize new colorsets to black on gray */
+       while (nColorsets <= n)
+       {
+               colorset_struct *ncs = &Colorset[nColorsets];
+
+               /* try to allocate private colormap entries if required */
+               if (privateCells && XAllocColorCells(
+                       /* grab four writeable cells */
+                       dpy, Pcmap, False, NULL, 0, &(ncs->fg), 4))
+               {
+                       XColor color;
+                       XColor *colorp;
+
+                       /* set the fg color */
+                       MyXParseColor(black, &color);
+                       color.pixel = ncs->fg;
+                       XStoreColor(dpy, Pcmap, &color);
+                       /* set the bg */
+                       MyXParseColor(gray, &color);
+                       color.pixel = ncs->bg;
+                       XStoreColor(dpy, Pcmap, &color);
+                       /* calculate and set the hilite */
+                       colorp = GetHiliteColor(ncs->bg);
+                       colorp->pixel = ncs->hilite;
+                       XStoreColor(dpy, Pcmap, colorp);
+                       /* calculate and set the shadow */
+                       colorp = GetShadowColor(ncs->bg);
+                       colorp->pixel = ncs->shadow;
+                       XStoreColor(dpy, Pcmap, colorp);
+               }
+               /* otherwise allocate shared ones and turn off private flag */
+               else
+               {
+                       sharedCells = True;
+                       privateCells = False;
+                       /* grab four shareable colors */
+                       if (Pdepth < 2) {
+                               char g_bits[] = {0x0a, 0x05, 0x0a, 0x05,
+                                                0x08, 0x02, 0x08, 0x02,
+                                                0x01, 0x02, 0x04, 0x08};
+                               /* monochrome monitors get black on white */
+                               /* with a gray pixmap background */
+                               ncs->fg = GetColor(black);
+                               ncs->bg = GetColor(white);
+                               ncs->hilite = GetColor(white);
+                               ncs->shadow = GetColor(black);
+                               ncs->pixmap = XCreatePixmapFromBitmapData(dpy,
+                                       Scr.NoFocusWin,
+                                       &g_bits[4 * (nColorsets % 3)], 4, 4,
+                                       BlackPixel(dpy, Scr.screen),
+                                       WhitePixel(dpy, Scr.screen), Pdepth);
+                               ncs->width = 4;
+                               ncs->height = 4;
+                       }
+                       else
+                       {
+                               ncs->fg = GetColor(black);
+                               ncs->bg = GetColor(gray);
+                               ncs->hilite = GetHilite(ncs->bg);
+                               ncs->shadow = GetShadow(ncs->bg);
+                       }
+                       /* set flags for fg contrast, bg average */
+                       /* in case just a pixmap is given */
+                       ncs->color_flags = FG_CONTRAST | BG_AVERAGE;
+               }
+               nColorsets++;
+       }
 }
 
 /* ---------------------------- builtin commands ---------------------------- 
*/

Reply via email to