]> Dogcows Code - chaz/openbox/blobdiff - otk_c/color.c
typesafety
[chaz/openbox] / otk_c / color.c
index 4ecca30cb21cea4924c28876ff047144bfa2eab9..732f7b7d8d5baf5ef7915649b3e62f28d2f1822c 100644 (file)
@@ -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;
This page took 0.021126 seconds and 4 git commands to generate.