summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/webenginewidgets/simplebrowser/main.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/examples/webenginewidgets/simplebrowser/main.cpp b/examples/webenginewidgets/simplebrowser/main.cpp
index 761403fb..750e7ae4 100644
--- a/examples/webenginewidgets/simplebrowser/main.cpp
+++ b/examples/webenginewidgets/simplebrowser/main.cpp
@@ -42,6 +42,18 @@
#include "browserwindow.h"
#include <QApplication>
+QString getCommandLineUrlArgument()
+{
+ const QStringList args = QCoreApplication::arguments();
+ if (args.count() > 1) {
+ const QString lastArg = args.last();
+ const bool isValidUrl = QUrl::fromUserInput(lastArg).isValid();
+ if (isValidUrl)
+ return lastArg;
+ }
+ return QString();
+}
+
int main(int argc, char **argv)
{
QApplication app(argc, argv);
@@ -50,9 +62,9 @@ int main(int argc, char **argv)
BrowserWindow *window = new BrowserWindow();
Browser::instance().addWindow(window);
- QStringList args = QCoreApplication::arguments();
- if (args.count() > 1)
- window->loadPage(args.last());
+ const QString url = getCommandLineUrlArgument();
+ if (!url.isEmpty())
+ window->loadPage(url);
else
window->loadHomePage();