Skip to content

Commit

Permalink
Fix 'cel.image = nil' is not allowed (fix aseprite#4514)
Browse files Browse the repository at this point in the history
Now 'cel.image = nil' results in the cel remotion.
  • Loading branch information
Gasparoken committed Nov 6, 2024
1 parent c83dd16 commit e140475
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/app/script/cel_class.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2018 David Capello
//
// This program is distributed under the terms of
Expand All @@ -9,6 +9,7 @@
#include "config.h"
#endif

#include "app/cmd/remove_cel.h"
#include "app/cmd/replace_image.h"
#include "app/cmd/set_cel_opacity.h"
#include "app/cmd/set_cel_position.h"
Expand Down Expand Up @@ -122,13 +123,16 @@ int Cel_set_frame(lua_State* L)
int Cel_set_image(lua_State* L)
{
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(new cmd::ReplaceImage(cel->sprite(),
cel->imageRef(),
newImage));
if (may_get_obj<Image>(L, 2)) {
const auto* srcImage = get_image_from_arg(L, 2);
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();
return 0;
}
Expand Down

0 comments on commit e140475

Please sign in to comment.