Whoops! Fixed infinite looping problem pointed out by Mr. Korman.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@698 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2002-04-08 17:40:31 +00:00
parent fdfdc4c9ae
commit c576508fb3
@@ -1,5 +1,5 @@
// //
// $Id: Controller.java,v 1.12 2002/04/07 21:59:25 shaper Exp $ // $Id: Controller.java,v 1.13 2002/04/08 17:40:31 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -320,11 +320,13 @@ public abstract class Controller
// scan up the component hierarchy looking for a controller on // scan up the component hierarchy looking for a controller on
// which to dispatch this action // which to dispatch this action
Component source = (Component)src; for (Component source = (Component)src; source != null;
do { source = source.getParent()) {
if (source instanceof ControllerProvider) { if (!(source instanceof ControllerProvider)) {
Controller ctrl = continue;
((ControllerProvider)source).getController(); }
Controller ctrl = ((ControllerProvider)source).getController();
if (ctrl == null) { if (ctrl == null) {
Log.warning("Provider returned null controller " + Log.warning("Provider returned null controller " +
"[provider=" + source + "]."); "[provider=" + source + "].");
@@ -337,6 +339,7 @@ public abstract class Controller
if (ctrl.handleAction(_action)) { if (ctrl.handleAction(_action)) {
return; return;
} }
} catch (Exception e) { } catch (Exception e) {
Log.warning("Controller choked on action " + Log.warning("Controller choked on action " +
"[ctrl=" + ctrl + "[ctrl=" + ctrl +
@@ -345,11 +348,6 @@ public abstract class Controller
} }
} }
// move up the hierarchy
source = source.getParent();
} while (source != null);
// if we got here, we didn't find a controller // if we got here, we didn't find a controller
Log.warning("Unable to find a controller to process action " + Log.warning("Unable to find a controller to process action " +
"[action=" + _action + "]."); "[action=" + _action + "].");