mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 04:20:46 +00:00
Fix memory management for cursors. In particular prevent the current
cursor from being deallocated when client code releases the last reference to it. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35586 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
daf0be3455
commit
2f3297119b
2 changed files with 15 additions and 7 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2012-09-21 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||||
|
|
||||||
|
* Source/NSCursor.m (+initialize, +pop, -push, -set): Fix memory
|
||||||
|
management for cursors. In particular prevent the current cursor
|
||||||
|
from being deallocated when client code releases the last
|
||||||
|
reference to it.
|
||||||
|
|
||||||
2012-09-21 Wolfgang Lux <wolfgang.lux@gmail.com>
|
2012-09-21 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||||
|
|
||||||
* Source/NSApplication.m (-targetForAction:, _targetForAction:window:,
|
* Source/NSApplication.m (-targetForAction:, _targetForAction:window:,
|
||||||
|
|
|
@ -63,10 +63,10 @@ static NSMutableDictionary *cursorDict = nil;
|
||||||
|
|
||||||
// Initialize class variables
|
// Initialize class variables
|
||||||
NSCursor_class = self;
|
NSCursor_class = self;
|
||||||
gnustep_gui_cursor_stack = [[NSMutableArray alloc] initWithCapacity: 2];
|
gnustep_gui_cursor_stack = [[NSMutableArray alloc] initWithCapacity: 1];
|
||||||
gnustep_gui_hidden_until_move = NO;
|
gnustep_gui_hidden_until_move = NO;
|
||||||
cursorDict = [NSMutableDictionary new];
|
cursorDict = [NSMutableDictionary new];
|
||||||
[[self arrowCursor] push];
|
[[self arrowCursor] set];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,13 +109,14 @@ static NSMutableDictionary *cursorDict = nil;
|
||||||
/*
|
/*
|
||||||
* The object we pop is the current cursor
|
* The object we pop is the current cursor
|
||||||
*/
|
*/
|
||||||
if ([gnustep_gui_cursor_stack count] > 1)
|
if ([gnustep_gui_cursor_stack count] > 0)
|
||||||
{
|
{
|
||||||
|
NSCursor *c = RETAIN([gnustep_gui_cursor_stack lastObject]);
|
||||||
[gnustep_gui_cursor_stack removeLastObject];
|
[gnustep_gui_cursor_stack removeLastObject];
|
||||||
gnustep_gui_current_cursor = [gnustep_gui_cursor_stack lastObject];
|
|
||||||
|
|
||||||
NSDebugLLog(@"NSCursor", @"Cursor pop");
|
NSDebugLLog(@"NSCursor", @"Cursor pop");
|
||||||
[gnustep_gui_current_cursor set];
|
[c set];
|
||||||
|
RELEASE(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +490,7 @@ backgroundColorHint:(NSColor *)bg
|
||||||
*/
|
*/
|
||||||
- (void) push
|
- (void) push
|
||||||
{
|
{
|
||||||
[gnustep_gui_cursor_stack addObject: self];
|
[gnustep_gui_cursor_stack addObject: gnustep_gui_current_cursor];
|
||||||
[self set];
|
[self set];
|
||||||
NSDebugLLog(@"NSCursor", @"Cursor push %p", _cid);
|
NSDebugLLog(@"NSCursor", @"Cursor push %p", _cid);
|
||||||
}
|
}
|
||||||
|
@ -498,7 +499,7 @@ backgroundColorHint:(NSColor *)bg
|
||||||
*/
|
*/
|
||||||
- (void) set
|
- (void) set
|
||||||
{
|
{
|
||||||
gnustep_gui_current_cursor = self;
|
ASSIGN(gnustep_gui_current_cursor, self);
|
||||||
if (_cid)
|
if (_cid)
|
||||||
{
|
{
|
||||||
[GSCurrentServer() setcursor: _cid];
|
[GSCurrentServer() setcursor: _cid];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue