From 3bf3d3fe7bcfa7933ecc2ec2f1607f586b2b00d8 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Wed, 26 Aug 2020 16:25:00 +0200 Subject: Cleanup qwebenginescript and qwebenginescriptcollection api This patch cleans up script and collection apis: * do not allocate user_script on heap, there is no need for that. * remove isNull(), which was used by collection.findScript(name) * remove collection.size(), there is already collection.count() * remove collection.findScript(name), user can use findScripts(name) which returns list of scripts or empty list if not found * collection.findScripts(name) is simply collection.find(name) [ChangeLog] Removed QWebEngineScriptCollection::findScript(name), use QWebEngineScriptCollection::find(name) instead. Change-Id: Iecf8f1d7c26275b9ce3a1ea97cf4bd74b17f681e Reviewed-by: Allan Sandfeld Jensen --- examples/webenginewidgets/stylesheetbrowser/mainwindow.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'examples/webenginewidgets') diff --git a/examples/webenginewidgets/stylesheetbrowser/mainwindow.cpp b/examples/webenginewidgets/stylesheetbrowser/mainwindow.cpp index c93205b18..bdf3c56bf 100644 --- a/examples/webenginewidgets/stylesheetbrowser/mainwindow.cpp +++ b/examples/webenginewidgets/stylesheetbrowser/mainwindow.cpp @@ -121,14 +121,15 @@ void MainWindow::removeStyleSheet(const QString &name, bool immediately) if (immediately) ui->webEngineView->page()->runJavaScript(s, QWebEngineScript::ApplicationWorld); - QWebEngineScript script = ui->webEngineView->page()->scripts().findScript(name); - ui->webEngineView->page()->scripts().remove(script); + const QList scripts = ui->webEngineView->page()->scripts().find(name); + if (!scripts.isEmpty()) + ui->webEngineView->page()->scripts().remove(scripts.first()); } bool MainWindow::hasStyleSheet(const QString &name) { - QWebEngineScript script = ui->webEngineView->page()->scripts().findScript(name); - return !script.isNull(); + const QList scripts = ui->webEngineView->page()->scripts().find(name); + return !scripts.isEmpty(); } void MainWindow::loadDefaultStyleSheets() -- cgit v1.2.3