mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-28 18:32:50 +00:00
[lua] Fix reported crash setting nil as user data (fix #4187)
This commit is contained in:
parent
10738b32c3
commit
82375462ae
@ -67,7 +67,7 @@ int UserData_set_text(lua_State* L) {
|
|||||||
const char* text = lua_tostring(L, 2);
|
const char* text = lua_tostring(L, 2);
|
||||||
auto wud = get_WithUserData<T>(obj);
|
auto wud = get_WithUserData<T>(obj);
|
||||||
UserData ud = wud->userData();
|
UserData ud = wud->userData();
|
||||||
ud.setText(text);
|
ud.setText(text ? std::string(text): std::string());
|
||||||
if (spr) {
|
if (spr) {
|
||||||
Tx tx;
|
Tx tx;
|
||||||
tx(new cmd::SetUserData(wud, ud, static_cast<Doc*>(spr->document())));
|
tx(new cmd::SetUserData(wud, ud, static_cast<Doc*>(spr->document())));
|
||||||
|
@ -135,3 +135,10 @@ do
|
|||||||
assert(spr.properties.a == "hi")
|
assert(spr.properties.a == "hi")
|
||||||
assert(spr.properties.b == 60)
|
assert(spr.properties.b == 60)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Test crash setting nil user data
|
||||||
|
-- https://github.com/aseprite/aseprite/issues/4187
|
||||||
|
do
|
||||||
|
local spr = Sprite(1, 1)
|
||||||
|
spr.data = nil
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user