move value sanitizing to WebEntityItem

This commit is contained in:
Stephen Birarda 2017-01-23 11:45:21 -08:00
parent 99e0c8c0e7
commit d7651e9838
2 changed files with 15 additions and 15 deletions

View file

@ -246,21 +246,14 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
}
void RenderableWebEntityItem::setSourceUrl(const QString& value) {
if (_sourceUrl != value) {
auto newURL = QUrl::fromUserInput(value);
auto valueBeforeSuperclassSet = _sourceUrl;
if (newURL.isValid()) {
qCDebug(entities) << "Setting web entity source URL to " << value;
_sourceUrl = newURL.toDisplayString();
} else {
qCDebug(entities) << "Clearing web entity source URL since" << value << "cannot be parsed to a valid URL.";
}
if (_webSurface) {
AbstractViewStateInterface::instance()->postLambdaEvent([this] {
_webSurface->getRootItem()->setProperty("url", _sourceUrl);
});
}
WebEntityItem::setSourceUrl(value);
if (_sourceUrl != valueBeforeSuperclassSet && _webSurface) {
AbstractViewStateInterface::instance()->postLambdaEvent([this] {
_webSurface->getRootItem()->setProperty("url", _sourceUrl);
});
}
}

View file

@ -125,7 +125,14 @@ bool WebEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const g
void WebEntityItem::setSourceUrl(const QString& value) {
if (_sourceUrl != value) {
_sourceUrl = value;
auto newURL = QUrl::fromUserInput(value);
if (newURL.isValid()) {
qCDebug(entities) << "Setting web entity source URL to " << value;
_sourceUrl = newURL.toDisplayString();
} else {
qCDebug(entities) << "Clearing web entity source URL since" << value << "cannot be parsed to a valid URL.";
}
}
}