Make -setNeedsDiplay: and -setNeedsDisplayInRect: thread safe.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16390 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
alexm 2003-04-08 00:17:53 +00:00
parent 219fb4b8da
commit 2c148286ee
3 changed files with 56 additions and 0 deletions

View file

@ -2082,8 +2082,28 @@ GSSetDragTypes(NSView* obj, NSArray *types)
return _visibleRect;
}
extern NSThread *GSAppKitThread; /* TODO */
- (void) _setNeedsDisplay_helper: (NSNumber *)v
{
[self setNeedsDisplay: [v boolValue]];
}
/**
* As an exception to the general rules for threads and -gui, this
* method is thread-safe and may be called from any thread.
*/
- (void) setNeedsDisplay: (BOOL)flag
{
if (GSCurrentThread() != GSAppKitThread)
{
[self performSelectorOnMainThread: @selector(_setNeedsDisplay_helper:)
withObject: [NSNumber numberWithBool: flag]
waitUntilDone: NO];
return;
}
if (flag)
{
[self setNeedsDisplayInRect: _bounds];
@ -2095,15 +2115,32 @@ GSSetDragTypes(NSView* obj, NSArray *types)
}
}
- (void) _setNeedsDisplayInRect_helper: (NSValue *)v
{
[self setNeedsDisplayInRect: [v rectValue]];
}
/**
* Inform the view system that the specified rectangle is invalid and
* requires updating. This automatically informs any superviews of
* any updating they need to do.
*
* As an exception to the general rules for threads and -gui, this
* method is thread-safe and may be called from any thread.
*/
- (void) setNeedsDisplayInRect: (NSRect)invalidRect
{
NSView *currentView = _super_view;
if (GSCurrentThread() != GSAppKitThread)
{
[self performSelectorOnMainThread: @selector(_setNeedsDisplayInRect_helper:)
withObject: [NSValue valueWithRect: invalidRect]
waitUntilDone: NO];
return;
}
/*
* Limit to bounds, combine with old _invalidRect, and then check to see
* if the result is the same as the old _invalidRect - if it isn't then