Skip to content

[controls/PageRouter]: Fix bug with extended properties when replacing a route with navigateToRoute

Jan Blackquill requested to merge work/janb/props-fix into master

if (current->name != incoming->name || current->data != incoming->data) { resolvedRoutes.replace(i, incoming); }

This codepath replaces resolvedRoutes[i] with incoming.

Shortly after, we do this:

resolvedRoutes[i]->properties.clear(); for (auto it = incoming->properties.constBegin(); it != incoming->properties.constEnd(); it++) { resolvedRoutes[i]->properties.insert(it.key(), it.value()); }

If the above conditional was evaluated and resolvedRoutes[i] was replaced with incoming, we would be clearing its properties map and then iterate through it, copying from incoming to resolvedRoutes[i] (alias of incoming). For obvious reasons, this fails, resulting in a blank map. Extracting out the properties map by value instead of by reference before this code and using the copy allows us to have the intended semantics.

Merge request reports

Loading