[rkward/releases/0.6.5] rkward/windows: Fix for output window not refreshing after output flush on Windows.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Sun Mar 13 19:57:11 UTC 2016


Git commit b6616cefd91c4c9b38b89181d53e8532e54abd13 by Thomas Friedrichsmeier.
Committed on 13/03/2016 at 19:56.
Pushed by tfry into branch 'releases/0.6.5'.

Fix for output window not refreshing after output flush on Windows.

Actually, a separate issue was that "refresh output" was broken, but this did not show as long as the auto-update mechanism was working.

BUG: 360236

M  +16   -1    rkward/windows/rkhtmlwindow.cpp
M  +1    -0    rkward/windows/rkhtmlwindow.h

http://commits.kde.org/rkward/b6616cefd91c4c9b38b89181d53e8532e54abd13

diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index 451c2c3..e53b7df 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -615,7 +615,7 @@ void RKHTMLWindowPart::initActions () {
 	outputFlush->setText (i18n ("&Flush Output"));
 	outputFlush->setIcon (KIcon ("edit-delete"));
 
-	outputRefresh = actionCollection ()->addAction ("output_refresh", window->page->action (QWebPage::ReloadAndBypassCache), SLOT (trigger()));
+	outputRefresh = actionCollection ()->addAction ("output_refresh", window, SLOT (refresh()));
 	outputRefresh->setText (i18n ("&Refresh Output"));
 	outputRefresh->setIcon (KIcon ("view-refresh"));
 
@@ -1023,6 +1023,13 @@ void RKOutputWindowManager::setCurrentOutputPath (const QString &_path) {
 	url.cleanPath ();
 	QString path = url.toLocalFile ();
 
+#ifdef Q_OS_WIN
+	// On windows, when flushing the output (i.e. deleting, re-creating it), KDirWatch seems to purge the file from the
+	// watch list (KDE 4.10.2; always?), so we need to re-add it. To make things complex, however, this may happen
+	// asynchronously, with this function called (via rk.set.output.html.file()), _before_ KDirWatch purges the file.
+	// To hack around the race condition, we re-watch the output file after a short delay.
+	QTimer::singleShot (100, this, SLOT (rewatchOutput ()));
+#endif
 	if (path == current_default_path) return;
 
 	if (!windows.contains (path)) {
@@ -1035,6 +1042,13 @@ void RKOutputWindowManager::setCurrentOutputPath (const QString &_path) {
 	current_default_path = path;
 }
 
+void RKOutputWindowManager::rewatchOutput () {
+	RK_TRACE (APP);
+	// called on Windows, only
+	file_watcher->removeFile (current_default_path);
+	file_watcher->addFile (current_default_path);
+}
+
 RKHTMLWindow* RKOutputWindowManager::getCurrentOutputWindow () {
 	RK_TRACE (APP);
 
@@ -1060,6 +1074,7 @@ void RKOutputWindowManager::fileChanged (const QString &path) {
 		window_list[i]->refresh ();
 		w = window_list[i];
 	}
+	RK_DEBUG (APP, DL_DEBUG, "changed %s, window %p", qPrintable (path), w);
 
 	if (w) {
 		if (RKSettingsModuleOutput::autoRaise ()) w->activate ();
diff --git a/rkward/windows/rkhtmlwindow.h b/rkward/windows/rkhtmlwindow.h
index 5104f14..f55c293 100644
--- a/rkward/windows/rkhtmlwindow.h
+++ b/rkward/windows/rkhtmlwindow.h
@@ -232,6 +232,7 @@ private:
 private slots:
 	void fileChanged (const QString &path);
 	void windowDestroyed (QObject *window);
+	void rewatchOutput ();
 };
 
 #endif



More information about the rkward-tracker mailing list