Skip to content

Commit

Permalink
Fix #1839 can delete reference images while properties are open
Browse files Browse the repository at this point in the history
Fix missing lang string in reference image dialog
  • Loading branch information
JannisX11 committed Apr 21, 2023
1 parent 5e2c287 commit d36d8c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions js/interface/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1826,6 +1826,7 @@ const BARS = {
icon: 'delete',
category: 'edit',
keybind: new Keybind({key: 46}),
condition: () => !Dialog.open,
click() {
let mesh_selection = Mesh.selected[0] && Project.mesh_selection[Mesh.selected[0].uuid];
if (ReferenceImageMode.active && ReferenceImage.selected) {
Expand Down
5 changes: 4 additions & 1 deletion js/preview/reference_images.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class ReferenceImage {
return ReferenceImage.selected == this;
}
save() {
if (this.removed) return this;
this.position[0] = Math.round(this.position[0]);
this.position[1] = Math.round(this.position[1]);
this.size[0] = Math.round(this.size[0]);
Expand All @@ -165,7 +166,7 @@ class ReferenceImage {
return this;
}
update() {
if (!Interface.preview) return this;
if (!Interface.preview || this.removed) return this;
let shown = this.resolveCondition();
if (!shown) {
this.node.remove();
Expand Down Expand Up @@ -533,6 +534,7 @@ class ReferenceImage {
case 'global': ReferenceImage.global.remove(this); break;
case 'built_in': ReferenceImage.built_in.remove(this); break;
}
this.removed = true;
this.save();
this.node.remove();
}
Expand Down Expand Up @@ -593,6 +595,7 @@ class ReferenceImage {
clear_mode: {type: 'checkbox', label: 'reference_image.clear_mode', value: this.clear_mode},
},
onConfirm: (result) => {
if (this.removed) return;
let clear_mode_before = this.clear_mode;
this.extend({
source: result.source,
Expand Down
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1865,6 +1865,7 @@
"texture.error.too_large": "Resolution exceeds the maximum of %0",
"texture.error.parent": "Texture file provided by parent model",

"reference_image.image": "Image",
"reference_image.position": "Position",
"reference_image.size": "Size",
"reference_image.rotation": "Rotation",
Expand Down

0 comments on commit d36d8c4

Please sign in to comment.