Closed wxtrac closed 3 years ago
My last patch concerning color allocation on 8-bit grafic systems was buggy. Sorry. There was a problem if two wxColours were allocated for the same RGB values. If the first wxColour was deleted this freed the colour from the X-colormap and thus the second, still used color, could be overridden from another application, which leads to a wrong color. The solution i found uses refernce counting. Now there exists a static array wxColouRefData::colMapAllocCounter which stores a reference counter for each entry in the colormap (mapped pixel value). On deletion of wxlColourRefData the colour is only freed from the X colormap if this counter reached 0. I've tested it on Linux and Sun machines with our application and it seems to work, colours are deallocated if they are no more in use and not deallocated if they are still used.
But i found some strange thing while looking into the gdk sources. It seems that they already do a colour refernce counting there and i don't really see why it don't work for the allocation from inside wxColour.
Robert, for your question regarding the color deallocation: // What happens if the colour has not been allocated // anew but has been found? RR. I don't have an exact answer for this either, but till now i've not regarded any problems.
Issue migrated from trac ticket # 4883
component: wxGTK | priority: normal
2000-12-22 09:54:49: benndorf created the issue