From 3e024822e6820bf29cdf555cfac180880d6fc962 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 4 Jun 2013 21:15:01 -0400 Subject: Fixed a bug where a file was loaded twice when auto reload was on diff --git a/src/mainwin.cc b/src/mainwin.cc index eedd3a5..7cebd7e 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -511,7 +511,8 @@ MainWindow::openFile(const QString &new_filename) } #endif setFileName(actual_filename); - + + fileChangedOnDisk(); // force cached autoReloadId to update refreshDocument(); updateRecentFiles(); if (actual_filename.isEmpty()) { @@ -627,10 +628,17 @@ void MainWindow::compile(bool reload, bool forcedone) // Reload checks the timestamp of the toplevel file and refreshes if necessary, if (reload) { + // Refresh files if it has changed on disk if (fileChangedOnDisk() && checkEditorModified()) { shouldcompiletoplevel = true; refreshDocument(); } + // If the file hasn't changed, we might still need to compile it + // if we haven't yet compiled the current text. + else { + QString current_doc = editor->toPlainText(); + if (current_doc != last_compiled_doc) shouldcompiletoplevel = true; + } } else { shouldcompiletoplevel = true; @@ -1052,7 +1060,10 @@ void MainWindow::actionShowLibraryFolder() void MainWindow::actionReload() { - if (checkEditorModified()) refreshDocument(); + if (checkEditorModified()) { + fileChangedOnDisk(); // force cached autoReloadId to update + refreshDocument(); + } } void MainWindow::hideEditor() -- cgit v0.10.1