Login | Register
My pages Projects Community openCollabNet

Discussions > dev > Re: svn commit: r1145 - trunk/src/org/tigris/gef/base/ModeManager.java

gef
Discussion topic

Back to topic list

Re: svn commit: r1145 - trunk/src/org/tigris/gef/base/ModeManager.java

Reply

Author dthompson
Full name Dave Thompson
Date 2008-11-29 00:51:18 PST
Message Hi Christian,

Is there a chance that a null mode might be passed into this class? This
seems an odd thing to do. Your new code will prevent bad things from
happening as a result, but won't it just mask bad code somewhere else?
Perhaps I'm missing something about modes. Maybe a mode being null is used
for some signalling purpose elsewhere.

I am curious because at the moment, I'm getting NPEs when trying to add a new
mode using Tom's new mechanism, but I thought that this was just my fault!

Dave

penyaskito at tigris dot org wrote:
> Author: penyaskito
> Date: 2008-11-28 15:05:01-0800
> New Revision: 1145
>
> Modified:
> trunk/src/org/tigris​/gef/base/ModeManage​r.java
>
> Log:
> Improved ModeManager for preventing NPE. Added count() for testability.
>
> Modified: trunk/src/org/tigris​/gef/base/ModeManage​r.java
> Url: http://gef.tigris.or​g/source/browse/gef/​trunk/src/org/tigris​/gef/base/ModeManage​r.java?view=diff​&rev=1145&p1=tru​nk/src/org/tigris/ge​f/base/ModeManager.j​ava&p2=trunk/src​/org/tigris/gef/base​/ModeManager.java​&r1=1144&r2=114​5
> ====================​====================​====================​==================
> --- trunk/src/org/tigris​/gef/base/ModeManage​r.java (original)
> +++ trunk/src/org/tigris​/gef/base/ModeManage​r.java 2008-11-28 15:05:01-0800
> @@ -101,6 +101,10 @@
> /** Add the given Mode to the stack if another instance
> * of the same class is not already on the stack. */
> public void push(FigModifyingMode newMode) {
> + if (newMode == null) {
> + LOG.info("A null mode was pushed. Ignoring.");
> + return;
> + }
> if(!includes(newMode​.getClass())) {
> _modes.addElement(newMode);
> //fireModeChanged();
> @@ -308,5 +312,12 @@
> m.paint(g);
> }
> }
> +
> + /**
> + * @return the number of modes in the stack.
> + */
> + public int count() {
> + return _modes.size();
> + }
>
> }
>
> --------------------​--------------------​--------------------​---------
> To unsubscribe, e-mail: commits-unsubscribe@​gef.tigris.org
> For additional commands, e-mail: commits-help at gef dot tigris dot org
>

« Previous message in topic | 1 of 4 | Next message in topic »

Messages

Show all messages in topic

Re: svn commit: r1145 - trunk/src/org/tigris/gef/base/ModeManager.java dthompson Dave Thompson 2008-11-29 00:51:18 PST
     Re: [gef-dev] Re: svn commit: r1145 - trunk/src/org/tigris/gef/base/ModeManager.java penyaskito Christian López Espínola 2008-11-29 03:45:52 PST
         Re: [gef-dev] Re: svn commit: r1145 - trunk/src/org/tigris/gef/base/ModeManager.java bobtarling Bob Tarling 2008-11-29 05:08:14 PST
             Re: [gef-dev] Re: svn commit: r1145 - trunk/src/org/tigris/gef/base/ModeManager.java penyaskito Christian López Espínola 2008-11-29 05:23:03 PST
Messages per page: