summaryrefslogtreecommitdiffstats
path: root/src/core/type_conversion.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-07-19 12:34:21 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-07-20 14:01:58 +0000
commit68ff88a1d767a64dd8d9b90615567789feebcefe (patch)
tree43ea11ec511585873f03b7245d3fa9a64fbfedbc /src/core/type_conversion.h
parent67e6b9e679856975161e85ee8011fac94b59bb22 (diff)
Make QUrl <-> GUrl conversion more explicit
Specify exactly how we parse using QUrl, and try parsing invalid URLs from GUrl as well. Change-Id: If6e95d2600315180f36f9ad767f97936b438cd84 Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Diffstat (limited to 'src/core/type_conversion.h')
-rw-r--r--src/core/type_conversion.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/core/type_conversion.h b/src/core/type_conversion.h
index 5181bc23d..b9e210c22 100644
--- a/src/core/type_conversion.h
+++ b/src/core/type_conversion.h
@@ -83,7 +83,7 @@ inline QString toQt(const base::string16 &string)
#endif
}
-inline QString toQt(const std::string &string)
+inline QString toQString(const std::string &string)
{
return QString::fromStdString(string);
}
@@ -93,6 +93,12 @@ inline QByteArray toQByteArray(const std::string &string)
return QByteArray::fromStdString(string);
}
+// ### should probably be toQByteArray
+inline QString toQt(const std::string &string)
+{
+ return toQString(string);
+}
+
inline base::string16 toString16(const QString &qString)
{
#if defined(OS_WIN)
@@ -109,12 +115,15 @@ inline base::NullableString16 toNullableString16(const QString &qString)
inline QUrl toQt(const GURL &url)
{
- return QUrl(QString::fromStdString(url.spec()));
+ if (url.is_valid())
+ return QUrl::fromEncoded(toQByteArray(url.spec()));
+
+ return QUrl(toQString(url.possibly_invalid_spec()));
}
inline GURL toGurl(const QUrl& url)
{
- return GURL(url.toString().toStdString());
+ return GURL(url.toEncoded().toStdString());
}
inline QPoint toQt(const gfx::Point &point)