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
_______________________________________________
Gnustep-dev mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/gnustep-dev