Fix crash trying to move pixels and the current layer is nullptr

This fix was found thanks to a user provided memory dump. We don't know
why the layer can be nullptr, but there are some conditions preventing
this situation already in other places of the StandbyState::onMouseDown()
member function.
This commit is contained in:
David Capello 2015-01-28 11:04:07 -03:00
parent dc7eeac2f8
commit 2a582638ec

View File

@ -243,7 +243,7 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
if (handle != NoHandle) { if (handle != NoHandle) {
int x, y, opacity; int x, y, opacity;
Image* image = location.image(&x, &y, &opacity); Image* image = location.image(&x, &y, &opacity);
if (image) { if (layer && image) {
if (!layer->isWritable()) { if (!layer->isWritable()) {
StatusBar::instance()->showTip(1000, StatusBar::instance()->showTip(1000,
"Layer '%s' is locked", layer->name().c_str()); "Layer '%s' is locked", layer->name().c_str());
@ -258,7 +258,7 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
} }
// Move selected pixels // Move selected pixels
if (editor->isInsideSelection() && msg->left()) { if (layer && editor->isInsideSelection() && msg->left()) {
if (!layer->isWritable()) { if (!layer->isWritable()) {
StatusBar::instance()->showTip(1000, StatusBar::instance()->showTip(1000,
"Layer '%s' is locked", layer->name().c_str()); "Layer '%s' is locked", layer->name().c_str());