Author: bobtarling
Date: 2008-11-04 14:56:20-0800
New Revision: 15966
Modified:
trunk/src/argouml-app/src/org/argouml/cognitive/ToDoList.java
trunk/src/argouml-app/src/org/argouml/cognitive/ToDoListEvent.java
trunk/src/argouml-app/src/org/argouml/cognitive/ui/ToDoPane.java
Log:
The remove list need doesn't need to be synchronized as it is a copy passed to other threads.
Modified: trunk/src/argouml-app/src/org/argouml/cognitive/ToDoList.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/cognitive/ToDoList.java?view=diff&rev=15966&p1=trunk/src/argouml-app/src/org/argouml/cognitive/ToDoList.java&p2=trunk/src/argouml-app/src/org/argouml/cognitive/ToDoList.java&r1=15965&r2=15966
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/cognitive/ToDoList.java (original)
+++ trunk/src/argouml-app/src/org/argouml/cognitive/ToDoList.java 2008-11-04 14:56:20-0800
@@ -163,8 +163,8 @@
* items on the list are still valid.
*/
public void run() {
- List<ToDoItem> removes =
- Collections.synchronizedList(new ArrayList<ToDoItem>());
+ final List<ToDoItem> removes = new ArrayList<ToDoItem>();
+
while (true) {
// the validity checking thread should wait if disabled.
@@ -195,8 +195,7 @@
* button via forceValidityCheck().
*/
public void forceValidityCheck() {
- List<ToDoItem> removes =
- Collections.synchronizedList(new ArrayList<ToDoItem>());
+ final List<ToDoItem> removes = new ArrayList<ToDoItem>();
forceValidityCheck(removes);
}
@@ -210,9 +209,10 @@
* <em>Warning: Fragile code!</em> No method that this method calls can
* synchronized the Designer, otherwise there will be deadlock.
*
- * @param removes a synchronized list containing the items to be removed
+ * @param removes a list containing the items to be removed
*/
- protected synchronized void forceValidityCheck(List<ToDoItem> removes) {
+ protected synchronized void forceValidityCheck(
+ final List<ToDoItem> removes) {
synchronized (items) {
for (ToDoItem item : items) {
boolean valid;
@@ -236,18 +236,16 @@
}
}
- synchronized (removes) {
- for (ToDoItem item : removes) {
- removeE(item);
- // History.TheHistory.addItemResolution(item,
- // "no longer valid");
- // ((ToDoItem)item).resolve("no longer valid");
- // notifyObservers("removeElement", item);
- }
- recomputeAllOffenders();
- recomputeAllPosters();
- fireToDoItemsRemoved(removes);
+ for (ToDoItem item : removes) {
+ removeE(item);
+ // History.TheHistory.addItemResolution(item,
+ // "no longer valid");
+ // ((ToDoItem)item).resolve("no longer valid");
+ // notifyObservers("removeElement", item);
}
+ recomputeAllOffenders();
+ recomputeAllPosters();
+ fireToDoItemsRemoved(removes);
}
/**
Modified: trunk/src/argouml-app/src/org/argouml/cognitive/ToDoListEvent.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/cognitive/ToDoListEvent.java?view=diff&rev=15966&p1=trunk/src/argouml-app/src/org/argouml/cognitive/ToDoListEvent.java&p2=trunk/src/argouml-app/src/org/argouml/cognitive/ToDoListEvent.java&r1=15965&r2=15966
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/cognitive/ToDoListEvent.java (original)
+++ trunk/src/argouml-app/src/org/argouml/cognitive/ToDoListEvent.java 2008-11-04 14:56:20-0800
@@ -25,6 +25,7 @@
package org.argouml.cognitive;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Vector;
@@ -53,7 +54,8 @@
* @param toDoItems the List of ToDoItems that were changed/added/removed
*/
public ToDoListEvent(final List<ToDoItem> toDoItems) {
- items = Collections.unmodifiableList(toDoItems);
+ items =
+ Collections.unmodifiableList(new ArrayList<ToDoItem>(toDoItems));
}
/**
Modified: trunk/src/argouml-app/src/org/argouml/cognitive/ui/ToDoPane.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/cognitive/ui/ToDoPane.java?view=diff&rev=15966&p1=trunk/src/argouml-app/src/org/argouml/cognitive/ui/ToDoPane.java&p2=trunk/src/argouml-app/src/org/argouml/cognitive/ui/ToDoPane.java&r1=15965&r2=15966
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/cognitive/ui/ToDoPane.java (original)
+++ trunk/src/argouml-app/src/org/argouml/cognitive/ui/ToDoPane.java 2008-11-04 14:56:20-0800
@@ -31,7 +31,6 @@
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
-import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
@@ -377,20 +376,7 @@
if (SwingUtilities.isEventDispatchThread()) {
task.run();
} else {
- // TODO: We really want to use invokeLater here but there is some
- // threading problem with doing so. I assume we have some problem
- // with the GUI querying the todo list as a reaction to a todo
- // event instead of only using the information contained within
- // that event.
- // With the current invokeAndWait solution we are blocking the GUI
- // in the todo thread - Bob.
- try {
- SwingUtilities.invokeAndWait(task);
- } catch (InterruptedException e) {
- LOG.error("Exception", e);
- } catch (InvocationTargetException e) {
- LOG.error("Exception", e);
- }
+ SwingUtilities.invokeLater(task);
}
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.