// saveTimer.setInterval(1000*10); // auto save every 20 seconds;
saveTimer.start();
}
+ listManager.saveRunner.noteSignals.noteSaveRunnerError.connect(this, "saveRunnerError(String, String)");
logger.log(logger.EXTREME, "Starting external file monitor timer");
externalFileSaveTimer = new QTimer();
if (!thumbnailViewer.isVisible())
thumbnailViewer.showFullScreen();
}
-
+ // An error happened while saving a note. Inform the user
+ @SuppressWarnings("unused")
+ private void saveRunnerError(String guid, String msg) {
+ if (msg == null) {
+ String title = "*Unknown*";
+ for (int i=0; i<listManager.getMasterNoteIndex().size(); i++) {
+ if (listManager.getMasterNoteIndex().get(i).getGuid().equals(guid)) {
+ title = listManager.getMasterNoteIndex().get(i).getTitle();
+ i=listManager.getMasterNoteIndex().size();
+ }
+ }
+ msg = "An error has happened saving the note \"" +title+
+ "\". \nThis is probably due to a document that is too complex for Nevernote to process. "+
+ "As a result, changes to the note may not be saved.\n\nPlease review the note for any potential problems.";
+
+ QMessageBox.information(this, tr("Error Saving Note"), tr(msg));
+ }
+ }
+
//**********************************************************
//**********************************************************
//* Online user actions
logger.log(logger.LOW, "End of modified note HTML");\r
// logger.log(logger.LOW, result.errorMessage);\r
// logger.log(logger.LOW, "Error Line:Column "+result.errorLine+":" +result.errorColumn);\r
- System.exit(16);\r
+ return null;\r
\r
\r
}\r
\r
// Fix XML that Evernote thinks is invalid\r
public String fixEnXMLCrap(String note) {\r
+ if (note == null)\r
+ return null;\r
+ \r
int pos;\r
StringBuffer buffer = new StringBuffer(note);\r
\r
public Signal2<String, String> guidChanged = new Signal2<String, String>();\r
public Signal1<Integer> titleColorChanged = new Signal1<Integer>();\r
public Signal2<Note, Boolean> noteDownloaded = new Signal2<Note, Boolean>();\r
+ public Signal2<String, String> noteSaveRunnerError = new Signal2<String, String>();\r
}\r
\r
\r
\r
import cx.fbn.nevernote.Global;\r
import cx.fbn.nevernote.evernote.EnmlConverter;\r
+import cx.fbn.nevernote.signals.NoteSignal;\r
import cx.fbn.nevernote.sql.DatabaseConnection;\r
import cx.fbn.nevernote.utilities.ApplicationLogger;\r
import cx.fbn.nevernote.utilities.Pair;\r
public QMutex threadLock;\r
private final DatabaseConnection conn;\r
private boolean idle;\r
+ public NoteSignal noteSignals;\r
\r
private volatile LinkedBlockingQueue<Pair<String, String>> workQueue = new LinkedBlockingQueue<Pair<String, String>>();\r
\r
conn = new DatabaseConnection(logger, u, uid, pswd, cpswd);\r
threadLock = new QMutex();\r
keepRunning = true;\r
+ noteSignals = new NoteSignal();\r
}\r
\r
\r
EnmlConverter enml = new EnmlConverter(logger);\r
String newContent = enml.convert(guid, content);\r
String fixedContent = enml.fixEnXMLCrap(newContent);\r
- conn.getNoteTable().updateNoteContent(guid, fixedContent);\r
-\r
-\r
- logger.log(logger.EXTREME, "Saving new note resources");\r
- List<Resource> oldResources = conn.getNoteTable().noteResourceTable.getNoteResources(guid, false);\r
- List<String> newResources = enml.getResources();\r
- removeObsoleteResources(oldResources, newResources);\r
- \r
+ if (fixedContent != null) {\r
+ conn.getNoteTable().updateNoteContent(guid, fixedContent);\r
+ logger.log(logger.EXTREME, "Saving new note resources");\r
+ List<Resource> oldResources = conn.getNoteTable().noteResourceTable.getNoteResources(guid, false);\r
+ List<String> newResources = enml.getResources();\r
+ removeObsoleteResources(oldResources, newResources);\r
+ } else {\r
+ noteSignals.noteSaveRunnerError.emit(guid, null);\r
+ }\r
logger.log(logger.HIGH, "Leaving ListManager.updateNoteContent");\r
}\r
\r
public TagSignal tagSignal;\r
public NotebookSignal notebookSignal;\r
private int trashCount;\r
- SaveRunner saveRunner; // Thread used to save content. Used because the xml conversion is slowwwww\r
+ public SaveRunner saveRunner; // Thread used to save content. Used because the xml conversion is slowwwww\r
QThread saveThread;\r
\r
// Constructor\r
System.out.println(newContent);\r
System.out.println("Location : Line-"+result.errorLine +" Column-" + result.errorColumn);\r
System.out.println("Exiting");\r
- System.exit(16);\r
+ content = null;\r
return;\r
}\r
\r
is.setCharacterStream(new StringReader(handler.getXml()));
if (validate) {
System.err.println("Error validating ENML2 DTD");
- System.exit(16);
+ return null;
}
} catch (SAXException e) {
System.err.append("SAXException");