OSDN Git Service

Correct bug where new notes may have data loss if typing while synchronizing.
authorRandy Baumgarte <randy@fbn.cx>
Thu, 16 Dec 2010 20:35:24 +0000 (15:35 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 19 Dec 2010 04:01:06 +0000 (23:01 -0500)
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/gui/NoteTableModel.java

index b9c7c61..d41a740 100644 (file)
@@ -4371,38 +4371,44 @@ public class NeverNote extends QMainWindow{
     @SuppressWarnings("unused")
        private void invalidateNoteCache(String guid, String content) {
        String v = noteCache.remove(guid);
-       if (content != null && !noteDirty) {
-               //noteCache.put(guid, content);
-       }
-               if (guid.equals(currentNoteGuid) && !noteDirty)
+//             if (guid.equals(currentNoteGuid) && !noteDirty)
                        refreshEvernoteNote(true);
     }
     // Signal received that a note guid has changed
     @SuppressWarnings("unused")
        private void noteGuidChanged(String oldGuid, String newGuid) {
        if (noteCache.containsKey(oldGuid)) {
-               String cache = noteCache.get(oldGuid);
-               noteCache.put(newGuid, cache);
-               noteCache.remove(oldGuid);
+               if (!oldGuid.equals(currentNoteGuid)) {
+                       String cache = noteCache.get(oldGuid);
+                       noteCache.put(newGuid, cache);
+                       noteCache.remove(oldGuid);
+               } else {
+                       noteCache.remove(oldGuid);
+                       noteCache.put(newGuid, browserWindow.getContent());
+               }
        }
+  
        listManager.updateNoteGuid(oldGuid, newGuid, false);
        if (currentNoteGuid.equals(oldGuid)) {
                if (currentNote != null)
                        currentNote.setGuid(newGuid);
                currentNoteGuid = newGuid;
        }
-               if (externalWindows.containsKey(oldGuid)) {
+               
+       if (externalWindows.containsKey(oldGuid)) {
                        ExternalBrowse b = externalWindows.get(oldGuid);
                        externalWindows.remove(oldGuid);
                        b.getBrowserWindow().getNote().setGuid(newGuid);
                        externalWindows.put(newGuid, b);
                }
+
        for (int i=0; i<listManager.getNoteIndex().size(); i++) {
                if (listManager.getNoteIndex().get(i).getGuid().equals(newGuid)) {
                        noteTableView.proxyModel.addGuid(newGuid);
                        i=listManager.getNoteIndex().size();
                }
        }
+       
        if (listManager.getNoteTableModel().titleColors.containsKey(oldGuid)) {
                int color = listManager.getNoteTableModel().titleColors.get(oldGuid);
                listManager.getNoteTableModel().titleColors.put(newGuid, color);
index 95c84ea..15a944d 100644 (file)
@@ -322,20 +322,25 @@ public class NoteTableModel extends QAbstractTableModel {
        }\r
 \r
        public void updateNoteGuid(String oldGuid, String newGuid) {\r
-               for (int i=0; i<getMasterNoteIndex().size(); i++) {\r
-                       if (getMasterNoteIndex().get(i).getGuid() != null && getMasterNoteIndex().get(i).getGuid().equals(oldGuid)) {\r
-                               getMasterNoteIndex().get(i).setGuid(newGuid);\r
-                               QModelIndex idx = createIndex(i, Global.noteTableGuidPosition, nativePointer());\r
-                               setData(idx, new String(getMasterNoteIndex().get(i).getGuid()), Qt.ItemDataRole.EditRole); \r
-                               i=getMasterNoteIndex().size()+1;\r
-                       }\r
-               }\r
+               \r
                for (int i=0; i<getNoteIndex().size(); i++) {\r
                        if (getNoteIndex().get(i).getGuid() != null && getNoteIndex().get(i).getGuid().equals(oldGuid)) {\r
                                getNoteIndex().get(i).setGuid(newGuid);; \r
                                i=getNoteIndex().size()+1;\r
                        }\r
                }\r
+               \r
+               boolean k = true;\r
+               if (k) return;\r
+               \r
+               for (int i=0; i<getMasterNoteIndex().size(); i++) {\r
+                       if (getMasterNoteIndex().get(i).getGuid() != null && getMasterNoteIndex().get(i).getGuid().equals(oldGuid)) {\r
+                               getMasterNoteIndex().get(i).setGuid(newGuid);\r
+//                             QModelIndex idx = createIndex(i, Global.noteTableGuidPosition, nativePointer());\r
+//                             setData(idx, new String(getMasterNoteIndex().get(i).getGuid()), Qt.ItemDataRole.EditRole); \r
+                               i=getMasterNoteIndex().size()+1;\r
+                       }\r
+               }               \r
        }\r
        \r
        public void updateNoteNotebook(String guid, String notebookGuid) {\r