From ca0920e81a490ef38e7fc1d0b70ad052bc20e475 Mon Sep 17 00:00:00 2001 From: nico Date: Mon, 18 Oct 1999 22:50:40 +0000 Subject: [PATCH] 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 --- Source/NSCell.m | 68 +++++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/Source/NSCell.m b/Source/NSCell.m index e0d3cedab..f2cf80d25 100644 --- a/Source/NSCell.m +++ b/Source/NSCell.m @@ -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 + } } } /*