ipad - CGColorReleaseing strokeColour Causes Crash Before Release Line -
i have little method coregraphics drawing. today using clang in xcode detect , fix memory leaks. told me 'rgbcolourspace' , 'fillcolour' (see code below). wondering why did not alert me 'strokecolour' had not released either. added block @ end of method, releases three. strangely enough, ipad app crash in line indicated below, above line release 'strokecolour' in.
// retrieve path supplied bedid cgpathref path = (cgpathref)[self.mydictionary objectforkey:bedid]; // save graphics state can restored later cgcontextsavegstate(self.bitmapcontext); // initialise fill , stroke colour cgcolorref fillcolour = [uicolor whitecolor].cgcolor; cgcolorref strokecolour = [uicolor blackcolor].cgcolor; // set stroke width cgcontextsetlinewidth(self.bitmapcontext, 1.0); // create cgcolorspace cgcolorspaceref rgbcolourspace = cgcolorspacecreatedevicergb(); // add path graphics context cgcontextaddpath(self.bitmapcontext, path); // set fill colour... cgcontextsetfillcolorwithcolor(self.bitmapcontext, fillcolour); // ...and stroke colour --> cgcontextsetstrokecolorwithcolor(self.bitmapcontext, strokecolour); // crashes here // draw path, fill , stroke cgcontextdrawpath(self.bitmapcontext, kcgpathfillstroke); // restore graphics state cgcontextrestoregstate(self.bitmapcontext); // notify view update [self.view setneedsdisplay]; // release rgbcolorspace , fillcolor cgcolorspacerelease(rgbcolourspace); cgcolorrelease(fillcolour); // cgcolorrelease(*strokecolour*); -- reason must not release this, or else app crashes further up.
this puzzles me, it's quite repeatable. if comment last line out, works; line activated crashes few lines above (line indicated above). what's going on? drawing not occurring when think is? happening later? , if so, why 'fillcolour' , 'rgbcolourspace' not have problem? hints appreciated. thank you.
you're not owner of fillcolour
, strokecolour
. not release them.
Comments
Post a Comment