Skip to content

Commit 5e0c8a9

Browse files
authored
Fix a crash in the sprite editor of a child-object (4ian#6266)
1 parent 977c102 commit 5e0c8a9

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

newIDE/app/src/ObjectEditor/Editors/SpriteEditor/SpritesList.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,8 @@ const SpritesList = ({
628628
onClick={() => {
629629
onAddSprite(resourceSources[0]);
630630
}}
631+
// The event-based object editor gives an empty list.
632+
disabled={resourceSources.length === 0}
631633
label={<Trans>Add a sprite</Trans>}
632634
icon={<Add />}
633635
primary

newIDE/app/src/ObjectEditor/Editors/SpriteEditor/index.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,9 @@ export default function SpriteEditor({
672672
<I18n>
673673
{({ i18n }) => (
674674
<>
675-
{spriteConfiguration.getAnimationsCount() === 0 ? (
675+
{spriteConfiguration.getAnimationsCount() === 0 &&
676+
// The event-based object editor gives an empty list.
677+
imageResourceExternalEditors.length > 0 ? (
676678
<Column noMargin expand justifyContent="center">
677679
<EmptyPlaceholder
678680
title={<Trans>Add your first animation</Trans>}
@@ -691,16 +693,9 @@ export default function SpriteEditor({
691693
onAction={() => {
692694
importImages();
693695
}}
694-
onSecondaryAction={
695-
imageResourceExternalEditors.length
696-
? () => {
697-
createAnimationWith(
698-
i18n,
699-
imageResourceExternalEditors[0]
700-
);
701-
}
702-
: undefined
703-
}
696+
onSecondaryAction={() => {
697+
createAnimationWith(i18n, imageResourceExternalEditors[0]);
698+
}}
704699
/>
705700
</Column>
706701
) : (

0 commit comments

Comments
 (0)