mirror of https://github.com/aseprite/aseprite.git
Fix 'cel.image = nil' is not allowed (fix #4514)
Now 'cel.image = nil' results in the cel remotion.
This commit is contained in:
parent
f7a9f44cec
commit
951c2d0de9
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2018-2023 Igara Studio S.A.
|
// Copyright (C) 2018-2024 Igara Studio S.A.
|
||||||
// Copyright (C) 2018 David Capello
|
// Copyright (C) 2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "app/cmd/remove_cel.h"
|
||||||
#include "app/cmd/replace_image.h"
|
#include "app/cmd/replace_image.h"
|
||||||
#include "app/cmd/set_cel_opacity.h"
|
#include "app/cmd/set_cel_opacity.h"
|
||||||
#include "app/cmd/set_cel_position.h"
|
#include "app/cmd/set_cel_position.h"
|
||||||
|
@ -122,13 +123,16 @@ int Cel_set_frame(lua_State* L)
|
||||||
int Cel_set_image(lua_State* L)
|
int Cel_set_image(lua_State* L)
|
||||||
{
|
{
|
||||||
auto cel = get_docobj<Cel>(L, 1);
|
auto cel = get_docobj<Cel>(L, 1);
|
||||||
auto srcImage = get_image_from_arg(L, 2);
|
|
||||||
ImageRef newImage(Image::createCopy(srcImage));
|
|
||||||
|
|
||||||
Tx tx(cel->sprite());
|
Tx tx(cel->sprite());
|
||||||
tx(new cmd::ReplaceImage(cel->sprite(),
|
if (may_get_obj<Image>(L, 2)) {
|
||||||
cel->imageRef(),
|
const auto* srcImage = get_image_from_arg(L, 2);
|
||||||
newImage));
|
const ImageRef newImage(Image::createCopy(srcImage));
|
||||||
|
tx(new cmd::ReplaceImage(cel->sprite(),
|
||||||
|
cel->imageRef(),
|
||||||
|
newImage));
|
||||||
|
}
|
||||||
|
else if (lua_isnil(L, 2))
|
||||||
|
tx(new cmd::RemoveCel(cel));
|
||||||
tx.commit();
|
tx.commit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue