X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=otk_c%2Fcolor.c;h=732f7b7d8d5baf5ef7915649b3e62f28d2f1822c;hb=57fec1aba539f195df2ded93d8c5c7f02c146619;hp=4ecca30cb21cea4924c28876ff047144bfa2eab9;hpb=9e4d1bbabcabef13b740dd7201e35c3314abfbee;p=chaz%2Fopenbox diff --git a/otk_c/color.c b/otk_c/color.c index 4ecca30c..732f7b7d 100644 --- a/otk_c/color.c +++ b/otk_c/color.c @@ -75,8 +75,6 @@ static void doCacheCleanup() { static void allocate(OtkColor *self) { XColor xcol; - assert(!self->allocated); - // allocate color from rgb values xcol.red = self->red | self->red << 8; xcol.green = self->green | self->green << 8; @@ -92,7 +90,6 @@ static void allocate(OtkColor *self) { } self->pixel = xcol.pixel; - self->allocated = True; if (cleancache) doCacheCleanup(); @@ -108,11 +105,9 @@ PyObject *OtkColor_FromRGB(int r, int g, int b, int screen) if (!colorcache) colorcache = PyDict_New(); - self->allocated = False; self->red = r; self->green = g; self->blue = b; - self->pixel = 0; self->screen = screen; // does this color already exist in the cache? @@ -124,6 +119,7 @@ PyObject *OtkColor_FromRGB(int r, int g, int b, int screen) // add it to the cache PyDict_SetItem(colorcache, (PyObject*)self, (PyObject*)self); + allocate(self); return (PyObject*)self; } @@ -136,11 +132,9 @@ PyObject *OtkColor_FromName(const char *name, int screen) if (!colorcache) colorcache = PyDict_New(); - self->allocated = False; self->red = -1; self->green = -1; self->blue = -1; - self->pixel = 0; self->screen = screen; parseColorName(self, name); @@ -154,16 +148,10 @@ PyObject *OtkColor_FromName(const char *name, int screen) // add it to the cache PyDict_SetItem(colorcache, (PyObject*)self, (PyObject*)self); + allocate(self); return (PyObject*)self; } -unsigned long OtkColor_Pixel(OtkColor *self) -{ - if (!self->allocated) - allocate(self); - return self->pixel; -} - void OtkColor_CleanupColorCache() { cleancache = True;