gnustep-dev
[Top][All Lists]
Advanced

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

Re: Graphos: works on Cocoa not on GNUstep


From: Riccardo Mottola
Subject: Re: Graphos: works on Cocoa not on GNUstep
Date: Mon, 10 Sep 2012 11:16:43 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120826 Firefox/15.0 SeaMonkey/2.12

Hi,



Can you help figuring out+ I thought about exceptions, but non is raised. I don't say it is a GS bug, it could be an error in Graphos about which Mac is more lenient...

It is certainly not a GS bug. Running Graphos with GNUstep under OS X I got a nice crash report when attempting to paste a text object:

Excellent, I prefer it to be a bug in my code, much easier to fix! And confirms that GS is maturing.

Given that Graphos crashes in a function like GSIMapAddPair, the most likely cause is a memory corruption. Looking at the code in GRText I see three objects passed to -dictionaryWithObjectsAndKeys:. Two of them, temp and style, are assigned locally in the -draw method and third is the attribute strokeColor. Now looking at the code of -initFromData:inView:zoomFactor:, which is the initializer used for pasted objects, I see that the strokeColor attribute is assigned an autoreleased color object. Retaining this object will avoid the crash (and FWIW, the same error is present for the fillColor attribute).

Well spotted. It was missing fior GRText for both colors, on creating and in other palces, colors are retained indeed.

I think the whole method, the concept and structure of which are still GDraw's, could be restructured. A child object should inherit from the parent object and initialize its own stuff: Thus common code would be written in only one place, limitign such errors (since allo drawable objects have a stroke color for example). Furthermore I don't like that the "zoom factor" is used during initialization: I think it is a property of the view, not of the object and thus should be used during drawing only.
What do you think?
This code works on OS X either because Cocoa is returning a preallocated color (you might try whether copying a text object with some non-standard color works) or because Cocoa uses a cache of color objects.
On my version, I did not get a crash for both "standard" as randomly choosen colors of the color wheel. For you it crashed though. I just ocmmited the fix, does it work for you on Mac now?

Thank you

Riccardo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]