Revision: 4001
Author: [email protected]
Date: Mon Nov 29 14:24:13 2010
Log: The root cause of this bug was that multiple sessions were open with an object containing matching UUIDs. The code to find the project that contained the object being dragged was not handling multiple identical projects being opened. Now if there are multiple projects a check is done to confirm that they are all the same project then the dragged object is considered to be dragged in the same project not dragged in from a different project.
http://code.google.com/p/power-architect/source/detail?r=4001

Modified:
 /trunk/src/main/java/ca/sqlpower/architect/swingui/ASUtils.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ASUtils.java Thu Jul 22 12:40:28 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ASUtils.java Mon Nov 29 14:24:13 2010
@@ -509,14 +509,25 @@
public static DuplicateProperties createDuplicateProperties(ArchitectSwingSession currentSession, SQLObject source) {
         ArchitectSwingSession containingSession = null;
final List<SQLObject> ancestorList = SQLObjectUtils.ancestorList(source); + List<ArchitectSwingSession> containingSessions = new ArrayList<ArchitectSwingSession>(); for (ArchitectSession s : currentSession.getContext().getSessions()) {
             ArchitectSwingSession session = (ArchitectSwingSession) s;
             SQLObjectRoot root = session.getRootObject();
             if (ancestorList.contains(root)) {
-                containingSession = session;
-                break;
+                containingSessions.add(session);
             }
         }
+        if (containingSessions.size() == 1) {
+            containingSession = containingSessions.get(0);
+ } else if (containingSessions.size() > 1) { //Used in the case where multiple of the same project is open at the same time.
+            for (ArchitectSwingSession session : containingSessions) {
+ if (!session.getWorkspace().getUUID().equals(currentSession.getWorkspace().getUUID())) { + throw new IllegalStateException("The object " + source + " exists in both " + + currentSession.getWorkspace() + " and " + session.getWorkspace() + " by UUID equality.");
+                }
+            }
+            containingSession = currentSession;
+        }
if (containingSession == null) { //The SQLObject source comes from outside this context.
             return new DuplicateProperties(
false, //This is technically possible but ridiculous. The Architects could be loaded from different pl.ini files.

Reply via email to