bug-gnustep
[Top][All Lists]
Advanced

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

Re: Fix, NSView (-releaseGState)


From: Georg Fleischmann
Subject: Re: Fix, NSView (-releaseGState)
Date: Mon, 13 Sep 2010 16:05:09 +0800

Hi Fred,

> if (_gstate)
>  if (_window)
>    GSUndefineGState([_window graphicsContext], _gstate);
>  _gstate = 0;

I added this at the beginning of _viewWillMoveToWindow: and played with some 
graphic windows in Cenon.
It will crash, if there is a _gstate but _window has no graphicsContext, which 
seems to be possible here.
If I add an additional test for [_window graphicsContext != nil, then I don't 
get any problems.

Georg


On 11.09.2010, at 20:17, Fred Kiefer wrote:

> Hi Georg,
> 
> thank you for this patch. It surely is correct and I will add it. But as
> you already pointed out there may be a deeper problem here.
> I think that we should always clean up the gstate when the window for a
> view changes, that is in the method _viewWillMoveToWindow:. Something like:
> 
> if (_gstate)
>  if (_window)
>    GSUndefineGState([_window graphicsContext], _gstate);
>  _gstate = 0;
> 
> Do you or anybody else on this list, see any problem with that change?
> 
> Fred
> 
> 
> Am 11.09.2010 12:24, schrieb Georg Fleischmann:
>> here is a small patch for NSView (SVN 2010-09-10 and before) to prevent a 
>> crash in Cenon when closing a Graphic Window.
>> The same code of Cenon works on Apple, so I suspect it's an issue with 
>> GNUstep.
>> 
>> The crash is in NSView, which has a gstate but no _window (_window = nil) to 
>> get the graphicsContext. This is causing the crash.
>> I simply tested for a _window != nil to prevent the crash, and everything 
>> appears to work.
>> 
>> There might be an issue with the order of releasing the hierarchy of windows 
>> and views or something in that line, creating the situation in the first 
>> place, but I'm not deep enough into that to have any idea.
>> I also add the stack of the situation.
>> 
>> Best wishes,
>> Georg Fleischmann
>> 
>> 
>> 
>> *** Source/NSView.m.old      2010-09-04 13:30:30.000000000 +0800
>> --- Source/NSView.m  2010-09-11 17:45:22.000000000 +0800
>> ***************
>> *** 2183,2189 ****
>>  */
>>  - (void) releaseGState
>>  {
>> !   if (_allocate_gstate && _gstate)
>>      GSUndefineGState([_window graphicsContext], _gstate);
>>    _gstate = 0;
>>    _allocate_gstate = NO;
>> --- 2183,2189 ----
>>  */
>>  - (void) releaseGState
>>  {
>> !   if (_allocate_gstate && _gstate && _window)
>>      GSUndefineGState([_window graphicsContext], _gstate);
>>    _gstate = 0;
>>    _allocate_gstate = NO;
> 




reply via email to

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