[jsword-devel] Patch for sidebar delete problem

Joe Walker joseph.walker at gmail.com
Wed Aug 25 08:06:18 MST 2004


Sorry DM, I dont understand. Are you saying that JList makes untrue
assumptions about how the model changes, so sometimes the model
changes and JList gets confused? That sounds like quite a serious bug
in JList.

It looks to me as though BitwisePassage.remove(...) calls
fireIntervalAdded(...) which calls PassageListModel.versesRemoved(...)
which calls the JList model listener, so it doesn't seem to be our
fault.
Rather than clone the Passage, shouldn't we have a kickJList() method
to do the work (and why can't we call that automatically??)

Confused.

Joe.

On Wed, 25 Aug 2004 09:01:48 -0400, DM Smith <dmsmith555 at yahoo.com> wrote:
> As I noted in an earlier e-mail, the problem with the sidebar delete was
> that the list's model was not changing via the list or list model
> interfaces. This breaks the list.
> 
> The PassageListModel is written to respond to external changes, but it
> does not work. Down in the bowels of the JList code are all kinds of
> assumptions on its invariant and it tries to get at data that is not
> there anymore.
> 
> Anyway, I have a hack. It does not solve the problem, but prevents it
> from happening. It works on a copy and sets the list model's data to it
> after changing it.
> 
> Index: PassageGuiUtil.java
> ===================================================================
> RCS file:
> /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/passage/PassageGuiUtil.java,v
> retrieving revision 1.4
> diff -u -r1.4 PassageGuiUtil.java
> --- PassageGuiUtil.java    16 Aug 2004 22:09:21 -0000    1.4
> +++ PassageGuiUtil.java    25 Aug 2004 12:52:27 -0000
> @@ -52,7 +52,10 @@
>      {
>          PassageListModel plm = (PassageListModel) list.getModel();
> 
> -        Passage ref = plm.getPassage();
> +        // TODO(DMS): this is a hack.
> +        // Model is not changing through list or model inteface
> +        // Therefore we have to work on a copy.
> +        Passage ref = (Passage) plm.getPassage().clone();
>          Object[] selected = list.getSelectedValues();
>          for (int i = 0; i < selected.length; i++)
>          {
> @@ -60,7 +63,7 @@
>              ref.remove(range);
>          }
> 
> -        list.setSelectedIndices(new int[0]);
> +        plm.setPassage(ref);
>      }
> 
>      /**
> 
> _______________________________________________
> jsword-devel mailing list
> jsword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/jsword-devel
>


More information about the jsword-devel mailing list