[Drawkit] Important Bug Fix

Graham Cox graham.cox at bigpond.com
Thu Jun 5 17:37:25 PDT 2008


I'm putting this on the list ahead of a downloadable update because  
it's fairly important.

In DKGradient.m, change the following function:

static int cmpColorStops (DKColorStop* lh, DKColorStop* rh, void  
*context)
{
	#pragma unused(context)
	
	float lp = [lh position];
	float rp = [rh position];
	
	if (lp < rp)
		return NSOrderedAscending;
	else if (lp > rp)
		return NSOrderedDescending;
	else
		return NSOrderedSame;
}


Previously the lh and rh parameters were passed as type id, now  
they're explicit. (Also update the prototype or remove it).

This change allows you to compile against the 10.5 SDK without any  
runtime problems. This might seem counter-intuitive and it is - took  
me 11 hours to track this one down - but the call to the -position  
method was corrupting memory when using the 10.5 SDK because new  
Leopard classes implement -position, returning larger data types than  
a float, which was overwriting memory leading to bizarre runtime bugs  
like sheets failing to work. The strong typing of lh and rh make sure  
the code is compiled correctly.

cheers, Graham


More information about the Drawkit mailing list