mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-04 13:59:46 +00:00
Fix crash in SelectedLayers::displace() when layerDelta is out of bounds
This commit is contained in:
parent
b4d423051e
commit
356d88b413
@ -81,7 +81,13 @@ void SelectedLayers::selectAllLayers(LayerGroup* group)
|
||||
|
||||
void SelectedLayers::displace(layer_t layerDelta)
|
||||
{
|
||||
// Do nothing case
|
||||
if (layerDelta == 0)
|
||||
return;
|
||||
|
||||
const SelectedLayers original = *this;
|
||||
|
||||
retry:;
|
||||
clear();
|
||||
|
||||
for (auto it : original) {
|
||||
@ -97,8 +103,20 @@ void SelectedLayers::displace(layer_t layerDelta)
|
||||
}
|
||||
}
|
||||
|
||||
if (layer)
|
||||
if (layer) {
|
||||
insert(layer);
|
||||
}
|
||||
// If some layer is outside the range it means that the delta is
|
||||
// too big (out of bounds), we reduce the delta and try again the
|
||||
// whole process.
|
||||
else {
|
||||
layerDelta -= SGN(layerDelta);
|
||||
if (layerDelta == 0) {
|
||||
m_set = original.m_set;
|
||||
break;
|
||||
}
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user