orrery crashing X
Martix
martix.cz at gmail.com
Fri Sep 3 11:53:26 CEST 2010
Hi,
thanks for patch. I think you found two bugs, first in Orrery and
second in X, because it didn't crash several months before (and it
shouldn't). Maybe it's caused by some regression in X or perhaps lots
of gdk_draw_points allocated too much memory and X has been killed by
OOM killer. You can test this condition with swap.
Regards,
Martix
2010/9/3 Benjamin Deering <ben_deering at swissmail.org>:
> Hello All,
>
> I've missed having orrery this summer. Today I took a look at why it
> was causing X to crash. The crash happens when the program calls
> gdk_draw_point for every star it displays. I changed my copy to draw
> all of the stars into a GdkPixbuf, then I copy the GdkPixbuf onto the
> drawable area.
>
> Maybe someone knows why lots of gdk_draw_points would crash X.
>
> I think using the GdkPixbuf is faster anyways, so I'll try to add this
> to the bug posted on the orrery project page.
>
> Ben
>
>
>
>
> --- orrery.c 2009-11-30 00:59:44.000000000 -0500
> +++ orrery/orrery.c 2010-09-02 20:16:24.000000000 -0400
> @@ -1188,6 +1188,7 @@
> readStarCatalog(fD);
> showingFaintStars = FALSE;
> }
> +
> nDarkGreyPoints = nGreyPoints = nWhitePoints = 0;
> darkGreyLimit = DARK_GREY_LIMIT/magScale;
> greyLimit = GREY_LIMIT/magScale;
> @@ -1238,12 +1239,47 @@
> }
> currentEntry = currentEntry->forwardPointer;
> }
> - if (nDarkGreyPoints > 0)
> - gdk_draw_points(pixmap, darkGreyGC, darkGreyPoints, nDarkGreyPoints);
> - if (nGreyPoints > 0)
> - gdk_draw_points(pixmap, greyGC, greyPoints, nGreyPoints);
> - if (nWhitePoints > 0)
> - gdk_draw_points(pixmap, whiteGC, whitePoints, nWhitePoints);
> + GdkPixbuf* starDrawingBuf = gdk_pixbuf_get_from_drawable( NULL,
> +
> pixmap,
> +
> gdk_colormap_get_system()
> +
> , 0, 0, 0, 0, displayWidth, displayHeight);
> + g_assert (gdk_pixbuf_get_bits_per_sample (starDrawingBuf) == 8);
> + guchar* p;
> + int rowstride = gdk_pixbuf_get_rowstride (starDrawingBuf);
> + guchar* pixels = gdk_pixbuf_get_pixels (starDrawingBuf);
> + int n_channels = gdk_pixbuf_get_n_channels (starDrawingBuf);
> + GdkGCValues starGCval;
> + GdkColor starColor;
> + int pointNum;
> + gdk_gc_get_values(darkGreyGC, &starGCval);
> + gdk_colormap_query_color( gdk_gc_get_colormap(darkGreyGC),
> starGCval.foreground.pixel, &starColor );
> + for( pointNum = 0; pointNum < nDarkGreyPoints; pointNum++)
> + {
> + p = pixels + darkGreyPoints[pointNum].y * rowstride +
> darkGreyPoints[pointNum].x * n_channels;
> + p[0] = starColor.red & 0xff;
> + p[1] = starColor.green & 0xff;
> + p[2] = starColor.blue & 0xff;
> + }
> + gdk_gc_get_values(greyGC, &starGCval);
> + gdk_colormap_query_color( gdk_gc_get_colormap(greyGC),
> starGCval.foreground.pixel, &starColor );
> + for( pointNum = 0; pointNum < nGreyPoints; pointNum++)
> + {
> + p = pixels + greyPoints[pointNum].y * rowstride +
> greyPoints[pointNum].x * n_channels;
> + p[0] = starColor.red & 0xff;
> + p[1] = starColor.green & 0xff;
> + p[2] = starColor.blue & 0xff;
> + }
> + gdk_gc_get_values(whiteGC, &starGCval);
> + gdk_colormap_query_color( gdk_gc_get_colormap(whiteGC),
> starGCval.foreground.pixel, &starColor );
> + for( pointNum = 0; pointNum < nWhitePoints; pointNum++)
> + {
> + p = pixels + whitePoints[pointNum].y * rowstride +
> whitePoints[pointNum].x * n_channels;
> + p[0] = starColor.red & 0xff;
> + p[1] = starColor.green & 0xff;
> + p[2] = starColor.blue & 0xff;
> + }
> + gdk_draw_pixbuf ( pixmap , NULL , starDrawingBuf,
> + 0, 0, 0, 0, displayWidth, displayHeight,
> GDK_RGB_DITHER_NORMAL, 0, 0 ) ;
> }
>
> void makeTimeString(char *string)
>
>
> _______________________________________________
> Openmoko community mailing list
> community at lists.openmoko.org
> http://lists.openmoko.org/mailman/listinfo/community
>
More information about the community
mailing list