Maniphest T48831

Icon Preview generation for textures and images
Closed, Resolved

Assigned To
None
Authored By
Andreas Esau (ndee)
Jul 12 2016, 9:29 AM
Tags
  • BF Blender
Subscribers
Andreas Esau (ndee)
Bastien Montagne (mont29)
Campbell Barton (campbellbarton)
Sergey Sharybin (sergey)

Description

System Information
Windows 7

Blender Version
2.77.a abf6f08

Short description of error
I am trying to use the preview functionality for textuers and images and display those icons via an enum property. I loop over all textures in bpy.data and generate an entry for the enum property. Icon for the enum property is set by the IconID I get from bpy.data.textures["tex"].preview.icon_id.
When I now generate a new texture, the icon gets also generated and displayed. The problem now starts when I when I reload the blend. The icons are not generated anymore. And I get an error in the console that the given IconID with its corresponding icon is not found. Is there a way to trigger the generation of an icon? Also Icons are not displayed by the template_icon_view.

Exact steps for others to reproduce the error
Just open the blend file. Generate some textures. Icons get generated. Save blend file and then reopen. Icons are missing.

Related Objects

Mentioned Here
rB51812fb502c0: Fix 48831, Step I: Mismatch issues bewteen ID icon and preview system.
rBeb04908ccdf0: Fix 48831, Step II: UI icon code was not able to update/generate 'auto ID…
T48813: Custom icon is not drawn on header / addons prefs panel

Event Timeline

Andreas Esau (ndee) created this task.Jul 12 2016, 9:29 AM
Andreas Esau (ndee) updated the task description.
Andreas Esau (ndee) added a comment.Jul 12 2016, 9:37 AM

Small addition.

I add a new texture of type "IMAGE" and give the texture an image as data.
When painting something on the image, the icon does only update if the Texture Panel is "open" where the original texture icon in the texture_slot is displayed. Otherwise the icon has the old cashed version. It updates once the texture_slot is visible and updates the the icon.

Andreas Esau (ndee) added a comment.Jul 12 2016, 11:02 AM

Here is a small gif showcasing the problem.

Sergey Sharybin (sergey) added a subscriber: Sergey Sharybin (sergey).Jul 12 2016, 1:59 PM

This seems to be similar to T48813. Caused by Blender not knowing anything about dependencies between interface elements. To me it's more like a TODO than a Bug.

@mon29, @Campbell Barton (campbellbarton), this is your area so leaving final decision up to you.

Sergey Sharybin (sergey) lowered the priority of this task from 90 to Normal.Jul 12 2016, 1:59 PM
Sergey Sharybin (sergey) added a comment.Jul 12 2016, 2:08 PM

This seems to be similar to T48813. Caused by Blender not knowing anything about dependencies between interface elements. To me it's more like a TODO than a Bug.

@mon29, @Campbell Barton (campbellbarton), this is your area so leaving final decision up to you.

Andreas Esau (ndee) added a comment.Jul 12 2016, 5:29 PM

I noticed that after reloading the blendfile blender crashes very often.
In the gif this also happens. I just open the same blendinstance in the back for the video purpose so it is not seeable.

So I would say this is sort of BUGGY and not just a feature TODO :)

Bastien Montagne (mont29) claimed this task.Jul 12 2016, 5:53 PM
Bastien Montagne (mont29) triaged this task as 50 priority.
Bastien Montagne (mont29) added subscribers: Campbell Barton (campbellbarton), Bastien Montagne (mont29).

Yes, there is the update issue, but as you said, this is considered TODO for now.

However, there are at least two other issues here:

  1. ID.icon_id and PreviewImage.icon_id are not ensured to be the same, as it should be (and previewimage one is not correctly cleared on file read either).
  2. Mere 'buttons from icon_id' UI code (ui_def_but_icon and its callgraph) are not able to generate/update their pictures when those are ID-auto-generated (and not loaded from filesystem).
Bastien Montagne (mont29) changed the task status from Unknown Status to Resolved.Jul 12 2016, 9:47 PM

OK, Everything should be fixed now (rB51812fb502 & rBeb04908cc).

@Andreas Esau (ndee) note however that you should rather use bpy.types.UILayout.icon(tex) to get an ID icon in theory… Now should not change anything though.

Andreas Esau (ndee) added a comment.Jul 12 2016, 9:55 PM

Oh wow.. that was a quick. I will test this. Thanks alot Bastien.

so this would get me a proper icon id?

tex = bpy.data.textures["text_name"]
icon_id = bpy.types.UILayout.icon(tex)
Andreas Esau (ndee) removed Bastien Montagne (mont29) as the assignee of this task.Jul 12 2016, 10:01 PM

Ok.. One last thing. I don't know if this is related or if I should create a custom bug report for that.

@Bastien Montagne (mont29)
The icon gets properly displayed for normal enum properties. But when I try to display the enum property as template_icon_view, the icons are not shown.
Is there a magic trick, or is this a bug and I should write an extra report for that?

Bastien Montagne (mont29) added a comment.Jul 12 2016, 10:06 PM
In T48831#381188, @Andreas Esau (ndee) wrote:

so this would get me a proper icon id?

tex = bpy.data.textures["text_name"]
icon_id = bpy.types.UILayout.icon(tex)

Yes, typically… Though again, now it should not make any difference, except that going through tex.preview forces Blender to create the PreviewImage immediately - not a big deal in practice.

In T48831#381189, @Andreas Esau (ndee) wrote:

The icon gets properly displayed for normal enum properties. But when I try to display the enum property as template_icon_view, the icons are not shown.

Don’t know about that, here it works perfectly now (using your demo file)…

Andreas Esau (ndee) added a comment.EditedJul 13 2016, 7:10 AM

@Bastien Montagne (mont29)
ok. Just tried out the latest blender build and icon_view works fine now! Awesome that this issues are resolved!