summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2024-11-22 12:58:15 +0100
committerChristian Strømme <christian.stromme@qt.io>2024-12-05 19:49:41 +0100
commitb069ab8547ef9f77ad4351bb68ecf9991282b658 (patch)
treeb58108aacb7026d835498bb3e5ccddb6b7e64a2e /src
parentac1a751e6f60748dc2a6bdf54569610fdc432efb (diff)
macOS: Flip the switch and make the native back-end the default
In practice this have been the case for anyone not installing QtWebEngine and the platform issue that we had, and that required special initialization set-up, hasn't been an issue and that code has been removed from 6.5 and newer (see: 5f15afaaf07586006b1731cadcb061fa23c71aef). With this change we'll use the native back-end by default on macOS. [ChangeLog][macOS] macOS will now use the native WebView backend by default, meaning QtWebEngine is no longer required on macOS. Change-Id: Iebcefddf93432c5184d495d286bdead679e423de Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/darwin/darwin.json3
-rw-r--r--src/plugins/darwin/qdarwinwebview.mm10
-rw-r--r--src/webview/qwebviewfactory.cpp4
3 files changed, 11 insertions, 6 deletions
diff --git a/src/plugins/darwin/darwin.json b/src/plugins/darwin/darwin.json
index daa9d6f..9f65fd4 100644
--- a/src/plugins/darwin/darwin.json
+++ b/src/plugins/darwin/darwin.json
@@ -1,4 +1,3 @@
{
- "Keys": ["native"],
- "RequiresInit": true
+ "Keys": ["native"]
}
diff --git a/src/plugins/darwin/qdarwinwebview.mm b/src/plugins/darwin/qdarwinwebview.mm
index 80b9916..d8950da 100644
--- a/src/plugins/darwin/qdarwinwebview.mm
+++ b/src/plugins/darwin/qdarwinwebview.mm
@@ -18,6 +18,7 @@
#include <WebKit/WebKit.h>
#include <QtCore/qjsondocument.h>
+#include <QtCore/qfile.h>
#ifdef Q_OS_IOS
#import <UIKit/UIKit.h>
@@ -360,6 +361,13 @@ void QDarwinWebViewPrivate::setUrl(const QUrl &url)
{
if (url.isValid()) {
if (url.isLocalFile()) {
+ // NOTE: Check if the file exists before attempting to load it, we follow the same
+ // asynchronous pattern as expected to not break the tests (Started + Failed).
+ if (!QFile::exists(url.toLocalFile())) {
+ QMetaObject::invokeMethod(this, &QDarwinWebViewPrivate::loadingChanged, Qt::QueuedConnection, QWebViewLoadRequestPrivate(url, QWebView::LoadStartedStatus, {}));
+ QMetaObject::invokeMethod(this, &QDarwinWebViewPrivate::loadingChanged, Qt::QueuedConnection, QWebViewLoadRequestPrivate(url, QWebView::LoadFailedStatus, QStringLiteral("File does not exist")));
+ return;
+ }
// We need to pass local files via loadFileURL and the read access should cover
// the directory that the file is in, to facilitate loading referenced images etc
if (m_settings->allowFileAccess()) {
@@ -371,6 +379,8 @@ void QDarwinWebViewPrivate::setUrl(const QUrl &url)
} else {
[wkWebView loadRequest:[NSURLRequest requestWithURL:url.toNSURL()]];
}
+ } else {
+ QMetaObject::invokeMethod(this, &QDarwinWebViewPrivate::loadingChanged, Qt::QueuedConnection, QWebViewLoadRequestPrivate(url, QWebView::LoadFailedStatus, QStringLiteral("Invalid URL")));
}
}
diff --git a/src/webview/qwebviewfactory.cpp b/src/webview/qwebviewfactory.cpp
index 657529f..ce00ce0 100644
--- a/src/webview/qwebviewfactory.cpp
+++ b/src/webview/qwebviewfactory.cpp
@@ -14,11 +14,7 @@ static QString getPluginName()
{
static const QString name = !qEnvironmentVariableIsEmpty("QT_WEBVIEW_PLUGIN")
? QString::fromLatin1(qgetenv("QT_WEBVIEW_PLUGIN"))
-#ifdef Q_OS_MACOS
- : QStringLiteral("webengine");
-#else
: QStringLiteral("native");
-#endif // Q_OS_MACOS
return name;
}