Re: [gtk-list] Re: Very small bug in gdk_gc_copy()



> Jon Trowbridge <trow@emccta.com> writes:
> 
> > The problem is with line 655 of gdkgc.c, the last real line of code in the
> > file.  It says:
> > 
> > XCopyGC (src_private->xdisplay, src_private->xgc, 0xffff, dst_private->xgc);
> > 
> > The 0xffff is not sufficient to make sure that all components of the
> > GC actually get copied.  Replacing it with 0xffffffff clears up the
> > problem under Linux on the Intel.  I don't actually know anything
> > about X, though, so I don't know if this is portable...
> 
> I think it should be OK. There is a _small_ chance that a server could
> be implemented in such a way that that would give a BadValue error
> (there are only 22 defined flags), but I think that is fairly
> unlikely. I've made the change.

Of course you could do it properly with the (odd looking) expression...

			~((~1) << GCLastBit);

Which, explained is...

		* Start with one bit set (because GCLastBit = 0 means one
					  bit of mask).

		  Bits: 00000000000000000000000000000001
		
		* Perform a bitwise NOT (Note doing these two steps rather
		  than 0xFFFFFFFE makes it independent of the size of the
		  bitmask).

		  Bits: 11111111111111111111111111111110

		* Left shift by GCLastBit, this shifts zeroes in for each
		  of the other bits (today GCLastBit is 22, since there are
		  _23_ defined flags - that's why we started with 1 bit set).

		  Bits: 11111111100000000000000000000000

		* Finally perform a second bitwise NOT	

		  Bits: 00000000011111111111111111111111

		* And there you have it.. the right number of bits, of the
		  right type.

Daniel.

-- 
Daniel Stephens (daniel@cheeseplant.org)
Systems Analyst - Linux, gcc, g++, Perl, GNU Advocate
"Nothing is _too_ weird" <A HREF="http://mall.lnd.com/daniels/">Home!?</A>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]