Rewritten part of performClick: to avoid various problems (crashing

included) when there is no control view.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5030 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 1999-10-18 22:50:40 +00:00
parent b6681852cc
commit 049355e6c0

View file

@ -824,38 +824,52 @@ static Class cellClass;
- (void) performClick: (id)sender
{
NSView *cv;
NSRect cvBounds;
NSWindow *cvWin;
if (control_view)
cv = control_view;
else
cv = [NSView focusView];
cvBounds = [cv bounds];
cvWin = [cv window];
SEL action = [self action];
[self highlight: YES withFrame: cvBounds inView: cv];
[cvWin flushWindow];
// Wait approx 1/5 seconds
[[NSRunLoop currentRunLoop]
runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.2]];
if (control_view)
{
NSRect cvBounds = [control_view bounds];
NSWindow *cvWin = [control_view window];
[self highlight: NO withFrame: cvBounds inView: cv];
[cvWin flushWindow];
[self highlight: YES withFrame: cvBounds inView: control_view];
[cvWin flushWindow];
if ([self action])
// Wait approx 1/10 seconds
[[NSRunLoop currentRunLoop]
runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];
[self highlight: NO withFrame: cvBounds inView: control_view];
[cvWin flushWindow];
if (action)
{
NS_DURING
{
[(NSControl *)control_view sendAction: action to: [self target]];
}
NS_HANDLER
{
[localException raise];
}
NS_ENDHANDLER
}
}
else // We have no control view. The best we can do is the following.
{
NS_DURING
if (action)
{
[(NSControl*)cv sendAction: [self action] to: [self target]];
}
NS_HANDLER
{
[localException raise];
}
NS_ENDHANDLER
NS_DURING
{
[[NSApplication sharedApplication] sendAction: action
to: [self target]
from: self];
}
NS_HANDLER
{
[localException raise];
}
NS_ENDHANDLER
}
}
}
/*