chiark / gitweb /
threading fixes: be properly idempotent etc. about setup - comments and extra debug...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Apr 2011 12:38:06 +0000 (13:38 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Apr 2011 12:38:11 +0000 (13:38 +0100)
src/net/chiark/yarrg/MarketUploader.java

index 864cf99..a6df497 100644 (file)
@@ -276,11 +276,17 @@ public class MarketUploader implements Runnable, TopLevelWindowListener, GUIInit
                EventQueue.invokeLater(this);
        }
 
+       /*
+        * We arrange to wait for the GUI to be initialised, then look at every top-level window,
+        * and if it 
+        */
         public void run() {
                if (dtxt!=null) dtxt.println("MarketUploader run()...");
                if (EventQueueMonitor.isGUIInitialized()) {
+                       if (dtxt!=null) dtxt.println("MarketUploader GUI already ready");
                        guiInitialized();
                } else {
+                       if (dtxt!=null) dtxt.println("MarketUploader waiting for GUI");
                        EventQueueMonitor.addGUIInitializedListener(this);
                }
        }
@@ -288,19 +294,25 @@ public class MarketUploader implements Runnable, TopLevelWindowListener, GUIInit
        public void guiInitialized() {
                Window ws[]= EventQueueMonitor.getTopLevelWindows();
                EventQueueMonitor.addTopLevelWindowListener(this);
-               for (int i=0; i<ws.length; i++)
+               for (int i=0; i<ws.length; i++) {
+                       if (dtxt!=null) dtxt.println("MarketUploader existing toplevel "+i);
                        topLevelWindowCreated(ws[i]);
+               }
        }
 
-       public void topLevelWindowDestroyed(Window w) {}
+       public void topLevelWindowDestroyed(Window w) {
+               if (dtxt!=null) dtxt.println("MarketUploader destroyed toplevel");
+       }
        
        public void topLevelWindowCreated(Window w) {
                if (frame!=null) 
                        // already got it
                        return;
-               if (!w.getAccessibleContext().getAccessibleName().equals("Puzzle Pirates"))
+               String name = w.getAccessibleContext().getAccessibleName();
+               if (dtxt!=null) dtxt.println("MarketUploader new toplevel "+name);
+               if (!name.equals("Puzzle Pirates"))
                        return;
-               // found it
+               if (dtxt!=null) dtxt.println("MarketUploader found toplevel, creating gui");
                window = w;
                createGUI();
                frame.setVisible(true);