[education/rkward] rkward/windows: Avoid recursively stacking up refreshes

Thomas Friedrichsmeier null at kde.org
Thu Apr 21 14:14:47 BST 2022


Git commit 04b5079651f1c802e085714fcdbcc294b91915ed by Thomas Friedrichsmeier.
Committed on 21/04/2022 at 13:14.
Pushed by tfry into branch 'master'.

Avoid recursively stacking up refreshes

M  +10   -1    rkward/windows/rkhtmlwindow.cpp

https://invent.kde.org/education/rkward/commit/04b5079651f1c802e085714fcdbcc294b91915ed

diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index 578ff1ef..8c9a155f 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -1120,7 +1120,16 @@ bool RKHelpRenderer::renderRKHelp (const QUrl &url, RKHTMLWindow* container) {
 				}
 				writeHTML(QString("<li><<a href=\"rkward://open/%1/\">%2</a>></li>\n").arg(category, i18n("Choose another file")));
 				writeHTML("</ul>\n");
-				if (container) QObject::connect(RKRecentUrls::notifier(), &RKRecentUrls::recentUrlsChanged, container, &RKHTMLWindow::refresh);
+				if (container) {
+					auto connection = new QMetaObject::Connection;
+					*connection = QObject::connect(RKRecentUrls::notifier(), &RKRecentUrls::recentUrlsChanged, container, [connection, container](){
+						// connection must self-destruct, as it will be re-created from refresh()
+						QObject::disconnect(*connection);
+						delete connection;
+						// also, delay the actual refresh, in case, e.g. several script files are opened at once
+						QTimer::singleShot(0, container, &RKHTMLWindow::refresh);
+					});
+				}
 			}
 		}
 		writeHTML (renderHelpFragment (*it));


More information about the rkward-tracker mailing list