diff options
| author | Peter Varga <pvarga@inf.u-szeged.hu> | 2025-10-29 10:01:05 +0100 |
|---|---|---|
| committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2025-10-31 09:22:18 +0100 |
| commit | d615e7d1b1cc27a50010296016d47c1b6d46be78 (patch) | |
| tree | 5376a5388bad89fb193f476536d8ba36508aa910 | |
| parent | c9e6019125568f2de7d40a8cd393ded7217ae930 (diff) | |
Examples: Start simplebrowser with OTR profile in single-process mode
Single-process mode doesn’t allow the use of multiple profiles.
Qt WebEngine creates an off-the-record (OTR) profile by default, but
simplebrowser then attempts to create a non-OTR profile for browsing.
Creating a second profile results in a fatal error.
Detect single-process mode, and if it is enabled, make the first
window use the OTR profile. This allows the browser to test
single-process issues without crashing on start.
Change-Id: I1f9d7f151054cc4f1bd27f59924032dc4502b646
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
| -rw-r--r-- | examples/webenginewidgets/simplebrowser/main.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/examples/webenginewidgets/simplebrowser/main.cpp b/examples/webenginewidgets/simplebrowser/main.cpp index ff4811eae..fa52789c5 100644 --- a/examples/webenginewidgets/simplebrowser/main.cpp +++ b/examples/webenginewidgets/simplebrowser/main.cpp @@ -21,6 +21,19 @@ QUrl commandLineUrlArgument() return QUrl(u"chrome://qt"_s); } +bool isSingleProcessMode() +{ + const QStringList args = QCoreApplication::arguments(); + if (args.contains("--single-process"_L1)) + return true; + + const QStringList flags = qEnvironmentVariable("QTWEBENGINE_CHROMIUM_FLAGS").split(u' '); + if (flags.contains("--single-process"_L1)) + return true; + + return false; +} + int main(int argc, char **argv) { QCoreApplication::setOrganizationName("QtExamples"); @@ -37,7 +50,8 @@ int main(int argc, char **argv) QUrl url = commandLineUrlArgument(); Browser browser; - BrowserWindow *window = browser.createHiddenWindow(); + bool offTheRecord = isSingleProcessMode(); + BrowserWindow *window = browser.createHiddenWindow(offTheRecord); window->tabWidget()->setUrl(url); window->show(); return app.exec(); |
