Avoid to create a route when the source is not defined

This commit is contained in:
samcake 2015-10-19 12:56:06 -07:00
parent 9ae1da371e
commit 3d8b7f9d10
3 changed files with 16 additions and 11 deletions

View file

@ -300,7 +300,7 @@ namespace controller {
const auto& destination = route->_destination;
// THis could happen if the route destination failed to create
// FIXME: Maybe do not create the route if the destination failed and avoid this case ?
if (!destination) {
if (!source || !destination) {
continue;
}

View file

@ -39,9 +39,14 @@ QObject* MappingBuilderProxy::from(const QScriptValue& source) {
}
QObject* MappingBuilderProxy::from(const Endpoint::Pointer& source) {
auto route = Route::Pointer(new Route());
route->_source = source;
return new RouteBuilderProxy(_parent, _mapping, route);
if (source) {
auto route = Route::Pointer(new Route());
route->_source = source;
return new RouteBuilderProxy(_parent, _mapping, route);
} else {
qCDebug(controllers) << "MappingBuilderProxy::from : source is null so no route created";
return nullptr;
}
}
QObject* MappingBuilderProxy::makeAxis(const QJSValue& source1, const QJSValue& source2) {

View file

@ -108,7 +108,7 @@ bool PolyLineEntityItem::setStrokeWidths(const QVector<float>& strokeWidths) {
bool PolyLineEntityItem::setNormals(const QVector<glm::vec3>& normals) {
_normals = normals;
if (_points.size() < 2 || _normals.size() < 2) {
if (_points.size() < 2 || _normals.size() < 2 || _strokeWidths.size() < 2) {
return false;
}