Fix incorrect red crosses in layer panel?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
Lukas
Posts: 1308
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Fix incorrect red crosses in layer panel?

Post by Lukas »

Does anyone know if there's a function or trick to get rid of incorrect red crosses in the layer panel?

I often have layers that contained something with a path to a file that was not found. Even after relocating the file manually or by script, the red crosses don't disappear in some cases. I would like to somehow clean that up, so I can see what files are actually still missing.
User avatar
synthsin75
Posts: 10043
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Fix incorrect red crosses in layer panel?

Post by synthsin75 »

Depends on the layer type. It could be a missing image or layerscript. I've never seen the X remain after correcting those. Do you have a file with an example of one of these problem layers?
User avatar
Lukas
Posts: 1308
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Fix incorrect red crosses in layer panel?

Post by Lukas »

Well, after saving and re-opening the file the crosses are gone. Because the files were not actually missing. So it’s not really possible to share and see what’s wrong with the file. It’s just Moho not updating the layer panels. There’s nothing wrong with the files.

It happens after opening files and Moho can’t access the source files anymore and then relinking them via script. (Working from home forces me to replace paths for projects a lot, while keeping the folder structure intact). If I link sources manually the group layers that once contained missing stuff also stays with a red cross until I save and re-open.

For a missing image (that is no longer missing but still has the red cross), moving it with the layer transform tool removes the cross... But it’d be nice to somehow update the layer panel’s icons without having to touch everything or having to save and re-open (only to find out 1 of the 100 layers had a valid red cross)

I was hoping for a UpdateUI kind of thing, or maybe something I could do while iterating trough layers that updates the icon. 🤷‍♂️
User avatar
hayasidist
Posts: 3584
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Fix incorrect red crosses in layer panel?

Post by hayasidist »

I suppose you've tried the obvious three:

MOHO.Redraw; MohoView:DrawMe; ScriptInterface:UpdateUI


A thought - not tried this, so I really am just brainstorming -- do you access a layer without making it the selected layer?

IOW might (e.g.):

ScriptInterface:SetSelLayer(ImageLayer)
ImageLayer:SetSourceImage(path)
ScriptInterface:UpdateUI()

do the trick??
User avatar
Lukas
Posts: 1308
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Fix incorrect red crosses in layer panel?

Post by Lukas »

Thanks, I will try all of those tomorrow!
User avatar
synthsin75
Posts: 10043
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Fix incorrect red crosses in layer panel?

Post by synthsin75 »

I'm not able to replicate this in v12.5 (Win). Every time I relink an asset, the X immediately goes away.

Maybe it has something to do with networked assets? If so, maybe that's what needs LM_SecureAccess (I've never known): http://mohoscripting.com/methods/607


Off-topic...Paul, do you know what "*5* notation will have been stripped off." means on this? >> http://mohoscripting.com/methods/607
User avatar
hayasidist
Posts: 3584
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Fix incorrect red crosses in layer panel?

Post by hayasidist »

synthsin75 wrote: Mon Mar 08, 2021 11:41 pm ...
Maybe it has something to do with networked assets? If so, maybe that's what needs LM_SecureAccess (I've never known): http://mohoscripting.com/methods/607
Off-topic...Paul, do you know what "*5* notation will have been stripped off." means on this? >> http://mohoscripting.com/methods/607
I've not used that routine either - so intuitive deduction only: If it's a PSD file the *n* suffix to filename identifies which layer within the file -- if so, IMO, that method description would benefit from a tweak to clarify that it's the layer sequence number within the PSD (There are a few places -- which, ofc, I can't now quickly find -- where mohoscripting.com refers to the suffix)
User avatar
Lukas
Posts: 1308
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Fix incorrect red crosses in layer panel?

Post by Lukas »

Unfortunately, none of those functions worked.

The incorrect cross is reproducible like this:
  1. Create a new document
  2. Import an image
  3. Put the image in a group
  4. Save the document
  5. Rename the image
  6. Close and re-open the document
  7. Say NO to relocate the image
  8. Rename the image file back to its original filename
  9. In Moho the image is now visible again, but both the group and the image layer have a red cross
Then:
  1. Use the transform tool on the image layer, the red cross will disappear from the image layer
  2. Use the transform tool on the group layer, the red cross will disappear from the group layer
Not sure what else will make it update the red cross. But I'm thinking I probably will have to do sometimes weird like pretend to set the layer transform to force it to update...
User avatar
Lukas
Posts: 1308
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Fix incorrect red crosses in layer panel?

Post by Lukas »

Just discovered if I click the "Text" tool and press "Cancel" it actually fixes all the red crosses. No idea why and if it's even possible to somehow do what that tool does trough lua, but it's something.
User avatar
Lukas
Posts: 1308
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Fix incorrect red crosses in layer panel?

Post by Lukas »

Okay, for images it fixes the issue if you unload the image before setting the new path!

Code: Select all

ImageLayer:UnloadImage()
ImageLayer:SetSourceImage(path)
The groups that contain those images are still showing the red crosses though.

Edit: Oh it doesn't always work. That's odd..
User avatar
hayasidist
Posts: 3584
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Fix incorrect red crosses in layer panel?

Post by hayasidist »

[working on this whilst you added the last two posts ... so some redundant info here ...]

I had a look at the layer transform tool... the only thing in there that seems relevant to a UI refresh is a mouseEvent.view:DrawMe() -- so assuming we're in a button script, and the moho.view:DrawMe() didn't work then it's likely that it's a core product thing ..

[edit] and the insert text tool just calls a core product routine so that makes it pretty certain it's something in there and not do-able via the script interface ..


another way to lose the red X in the layers window for both image and group ---> select the image layer - right click - reference layer - ctrl-z

still less than ideal but ...
User avatar
Lukas
Posts: 1308
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Fix incorrect red crosses in layer panel?

Post by Lukas »

Ah yes, the script that I am running is a button script. So I guess that's why I can't refresh the UI properly.

I run it automatically when opening a file (trough an IsEnabled function that makes sure it's only running once), which is really convenient because pretty much all the files I open have wrong paths, and when I save them I need other people back on the other end to be able to open them too and reverse the paths again. It works quite well, except for documents having hundreds of red crosses sometimes...
User avatar
hayasidist
Posts: 3584
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Fix incorrect red crosses in layer panel?

Post by hayasidist »

sounds like a trip to Jira is needed...
User avatar
Lukas
Posts: 1308
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Fix incorrect red crosses in layer panel?

Post by Lukas »

Here we gooo 🚀
User avatar
synthsin75
Posts: 10043
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Fix incorrect red crosses in layer panel?

Post by synthsin75 »

hayasidist wrote: Tue Mar 09, 2021 8:18 am
synthsin75 wrote: Mon Mar 08, 2021 11:41 pm Off-topic...Paul, do you know what "*5* notation will have been stripped off." means on this? >> http://mohoscripting.com/methods/607
I've not used that routine either - so intuitive deduction only: If it's a PSD file the *n* suffix to filename identifies which layer within the file -- if so, IMO, that method description would benefit from a tweak to clarify that it's the layer sequence number within the PSD (There are a few places -- which, ofc, I can't now quickly find -- where mohoscripting.com refers to the suffix)
Ah, thanks Paul. That makes perfect sense.
Post Reply