OSDN Git Service

Alter shutdown logic to try and remove hang on shutdown when synchronizing.
authorRandy Baumgarte <randy@fbn.cx>
Sat, 12 Mar 2011 14:29:21 +0000 (09:29 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 3 Apr 2011 18:02:07 +0000 (14:02 -0400)
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/threads/SyncRunner.java

index 3f4a0d7..045866f 100644 (file)
@@ -1003,7 +1003,13 @@ public class NeverNote extends QMainWindow{
                        //try {
                                logger.log(logger.MEDIUM, "Waiting for syncThread to stop");
                                System.out.println(tr("Synchronizing.  Please be patient."));
-                               while (!syncRunner.isIdle());
+                               for(;syncRunner.thread().isAlive();) {
+                                       try {
+                                               wait(10);
+                                       } catch (InterruptedException e) {
+                                               e.printStackTrace();
+                                       }
+                               }
                                logger.log(logger.MEDIUM, "Sync thread has stopped");
                        //} catch (InterruptedException e1) {
                        //      e1.printStackTrace();
index d24aa23..c5e96b4 100644 (file)
@@ -193,8 +193,10 @@ public class SyncRunner extends QObject implements Runnable {
                        while(keepRunning) {\r
                                String work = workQueue.take();\r
                                logger.log(logger.EXTREME, "Work found: " +work);\r
-                               if (work.equalsIgnoreCase("stop"))\r
+                               if (work.equalsIgnoreCase("stop")) {\r
+                                       idle=false;\r
                                        return;\r
+                               }\r
                                idle=false;\r
                                error=false;\r
                                if (authRefreshNeeded == true || !isConnected) {\r