OSDN Git Service

Merge branch 'japaneseSearch' into develop
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / NeverNote.java
index 48bc3f5..a0322c9 100644 (file)
@@ -47,7 +47,6 @@ import java.util.Vector;
 
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
-import org.apache.thrift.TException;
 import org.h2.tools.ChangeFileEncryption;
 
 import com.evernote.edam.error.EDAMNotFoundException;
@@ -66,6 +65,7 @@ import com.evernote.edam.type.Resource;
 import com.evernote.edam.type.SavedSearch;
 import com.evernote.edam.type.Tag;
 import com.evernote.edam.type.User;
+import com.evernote.thrift.TException;
 import com.trolltech.qt.QThread;
 import com.trolltech.qt.core.QByteArray;
 import com.trolltech.qt.core.QDateTime;
@@ -208,6 +208,7 @@ import cx.fbn.nevernote.xml.ExportData;
 import cx.fbn.nevernote.xml.ImportData;
 import cx.fbn.nevernote.xml.ImportEnex;
 import cx.fbn.nevernote.xml.NoteFormatter;
+//import org.apache.thrift.TException;
 
 
 public class NeverNote extends QMainWindow{
@@ -328,12 +329,14 @@ public class NeverNote extends QMainWindow{
     int                                        tagDeadCount=0;                         // number of consecutive dead times for the tag thread
     int                                        trashDeadCount=0;                       // number of consecutive dead times for the trash thread
     int                                saveThreadDeadCount=0;          // number of consecutive dead times for the save thread
+    int                                enRelatedNotesThreadDeadCount=0;        // number of consecutive dead times for the EvernoteRelatedNotes Thread
     boolean                            disableTagThreadCheck=false;
     boolean                            disableNotebookThreadCheck=false;
     boolean                            disableTrashThreadCheck=false;
     boolean                            disableSaveThreadCheck=false;
     boolean                            disableSyncThreadCheck=false;
     boolean                            disableIndexThreadCheck=false;
+    boolean                            disableENRelatedNotesThreadCheck=false;
     
     HashMap<String, String>            noteCache;                      // Cash of note content 
     HashMap<String, Boolean>   readOnlyCache;          // List of cashe notes that are read-only
@@ -625,7 +628,7 @@ public class NeverNote extends QMainWindow{
         
                // ICHANGED
                // 連想ノートリストをセットアップ
-               rensoNoteList = new RensoNoteList(conn, this);
+               rensoNoteList = new RensoNoteList(conn, this, syncRunner);
                rensoNoteList.itemPressed.connect(this,
                                "rensoNoteItemPressed(QListWidgetItem)");
                rensoNoteListDock = new QDockWidget(tr("Renso Note List"), this);
@@ -1250,6 +1253,9 @@ public class NeverNote extends QMainWindow{
                saveNote();
                listManager.stop();
                saveWindowState();
+               
+               // 連想ノートリストのEvernote関連ノート取得スレッドを終了
+               rensoNoteList.stopThread();
 
                if (tempFiles != null)
                        tempFiles.clear();
@@ -6742,7 +6748,15 @@ public class NeverNote extends QMainWindow{
                } else
                        indexThreadDeadCount=0;
 
-               
+               if (!rensoNoteList.getEnRelatedNotesThread().isAlive()) {
+                       enRelatedNotesThreadDeadCount++;
+                       if (enRelatedNotesThreadDeadCount > MAX && !disableENRelatedNotesThreadCheck) {
+                               QMessageBox.information(this, tr("A thread has died."), tr("It appears as the Evernote Related Notes thread has died.  I recommend "+
+                                       "checking stopping NeighborNote, saving the logs for later viewing, and restarting.  Sorry."));
+                               disableENRelatedNotesThreadCheck = true;
+                       }
+               } else
+                       enRelatedNotesThreadDeadCount=0;
        }
 
        private void thumbnailTimer() {
@@ -7756,4 +7770,9 @@ public class NeverNote extends QMainWindow{
                fromHistory.put(from,  fromHistory.get(to));
                fromHistory.put(to, fromHist);
        }
+       
+       // 連想ノートリストのgetter
+       public RensoNoteList getRensoNoteList() {
+               return rensoNoteList;
+       }
 }