summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-06-06 01:40:30 (GMT)
committerMarius Kintel <marius@kintel.net>2013-06-06 01:40:30 (GMT)
commitf49ba90cb51874671d8106ed89caeb0e9d6f3ae1 (patch)
tree8dfdebf7daed8949401c76da765b95d5c4ba27a1
parent6b16a0f8916c08201353faa8cd116e22b421dc3f (diff)
Fixed a bug where a file was loaded twice when auto reload was on
-rw-r--r--src/mainwin.cc22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 785aec6..db161d7 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -464,7 +464,6 @@ void MainWindow::report_func(const class AbstractNode*, void *vp, int mark)
MainWindow *thisp = static_cast<MainWindow*>(vp);
int v = (int)((mark*1000.0) / progress_report_count);
int permille = v < 1000 ? v : 999;
- printf("Progress: %d\n", permille);
if (permille > thisp->progresswidget->value()) {
QMetaObject::invokeMethod(thisp->progresswidget, "setValue", Qt::QueuedConnection,
Q_ARG(int, permille));
@@ -506,6 +505,7 @@ MainWindow::openFile(const QString &new_filename)
#endif
setFileName(actual_filename);
+ fileChangedOnDisk(); // force cached autoReloadId to update
refreshDocument();
updateRecentFiles();
if (actual_filename.isEmpty()) {
@@ -973,7 +973,10 @@ void MainWindow::actionShowLibraryFolder()
void MainWindow::actionReload()
{
- if (checkEditorModified()) refreshDocument();
+ if (checkEditorModified()) {
+ fileChangedOnDisk(); // force cached autoReloadId to update
+ refreshDocument();
+ }
}
void MainWindow::hideEditor()
@@ -1064,9 +1067,18 @@ bool MainWindow::compileTopLevelDocument(bool reload)
if (includesChanged()) shouldcompiletoplevel = true;
- if (reload && fileChangedOnDisk() && checkEditorModified()) {
- shouldcompiletoplevel = true;
- refreshDocument();
+ 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;
+ }
}
if (shouldcompiletoplevel) {
contact: Jan Huwald // Impressum