mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 05:10:58 +00:00
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:
parent
219fb4b8da
commit
2c148286ee
3 changed files with 56 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2003-04-08 02:12 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
|
* Source/NSApplication.m: Note which thread is the -gui thread.
|
||||||
|
|
||||||
|
* Source/NSView.m (-setNeedsDisplay:, -setNeedsDisplayInRect:):
|
||||||
|
If the current thread isn't the -gui thread, perform the call
|
||||||
|
in the main thread instead.
|
||||||
|
|
||||||
2003-04-07 13:05 Alexander Malmberg <alexander@malmberg.org>
|
2003-04-07 13:05 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
* Source/NSFont.m (-initWithName:matrix:fix:screenFont:): Release
|
* Source/NSFont.m (-initWithName:matrix:fix:screenFont:): Release
|
||||||
|
|
|
@ -72,6 +72,9 @@
|
||||||
#include <AppKit/GSGuiPrivate.h>
|
#include <AppKit/GSGuiPrivate.h>
|
||||||
#include <AppKit/GSInfoPanel.h>
|
#include <AppKit/GSInfoPanel.h>
|
||||||
|
|
||||||
|
/* The -gui thread. See the comment in initialize_gnustep_backend. */
|
||||||
|
NSThread *GSAppKitThread;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Base library exception handler
|
* Base library exception handler
|
||||||
*/
|
*/
|
||||||
|
@ -157,6 +160,14 @@ initialize_gnustep_backend(void)
|
||||||
{
|
{
|
||||||
Class backend;
|
Class backend;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Remember which thread we are running in. This thread will be the
|
||||||
|
-gui thread, ie. the only thread that may do any rendering. With
|
||||||
|
the exception of a few methods explicitly marked as thread-safe,
|
||||||
|
other threads should not call any methods in -gui.
|
||||||
|
*/
|
||||||
|
GSAppKitThread = [NSThread currentThread];
|
||||||
|
|
||||||
first = 0;
|
first = 0;
|
||||||
#ifdef BACKEND_BUNDLE
|
#ifdef BACKEND_BUNDLE
|
||||||
{
|
{
|
||||||
|
|
|
@ -2082,8 +2082,28 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
return _visibleRect;
|
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
|
- (void) setNeedsDisplay: (BOOL)flag
|
||||||
{
|
{
|
||||||
|
if (GSCurrentThread() != GSAppKitThread)
|
||||||
|
{
|
||||||
|
[self performSelectorOnMainThread: @selector(_setNeedsDisplay_helper:)
|
||||||
|
withObject: [NSNumber numberWithBool: flag]
|
||||||
|
waitUntilDone: NO];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
[self setNeedsDisplayInRect: _bounds];
|
[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
|
* Inform the view system that the specified rectangle is invalid and
|
||||||
* requires updating. This automatically informs any superviews of
|
* requires updating. This automatically informs any superviews of
|
||||||
* any updating they need to do.
|
* 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
|
- (void) setNeedsDisplayInRect: (NSRect)invalidRect
|
||||||
{
|
{
|
||||||
NSView *currentView = _super_view;
|
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
|
* 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
|
* if the result is the same as the old _invalidRect - if it isn't then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue