load Text File with Python from GUI Button results in 0 User #55260

Closed
opened 2018-05-30 17:35:25 +02:00 by Doc Holiday · 6 comments

System Information
Win 7 64 - AMD R9 380

Blender Version
Broken: 2.79
Worked: (2.74)

Short description of error
A loaded Text File with Python from GUI Button results in 0 User, and the Textblock ist marked red.

Exact steps for others to reproduce the error
Here is a blend. Load Script Bug (Studie).zip
Run the Script with Alt+P. It creates a Panel in the scene context of the properties editor.
Place a TXT on the C:\ Drive to load. Load it with the Button. Maybe you need to adjust the Filename in the Script bevore.
See what happens to the loaded Text in the Text Editior.

Regards, Doc

**System Information** Win 7 64 - AMD R9 380 **Blender Version** Broken: 2.79 Worked: (2.74) **Short description of error** A loaded Text File with Python from GUI Button results in 0 User, and the Textblock ist marked red. **Exact steps for others to reproduce the error** Here is a blend. [Load Script Bug (Studie).zip](https://archive.blender.org/developer/F3521003/Load_Script_Bug__Studie_.zip) Run the Script with Alt+P. It creates a Panel in the scene context of the properties editor. Place a TXT on the C:\ Drive to load. Load it with the Button. Maybe you need to adjust the Filename in the Script bevore. See what happens to the loaded Text in the Text Editior. Regards, Doc
Author

Added subscriber: @doc_holiday

Added subscriber: @doc_holiday
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Bastien Montagne was assigned by Philipp Oeser 2018-05-31 11:21:20 +02:00
Member

I think this has to do with commit blender/blender@a9163f7d22, blender/blender@646aa40cf7 (which only ensured real user for doing it from the UI?).
Also see blender/blender@15eb83c8b3.
Doing this from python [via bpy.ops.text.open] would skip this step because SpaceText as well as PropertyPointerRNA are not set in this case.
Doing this from python [via bpy.data.texts.load] would also skip this.

I think something like D3447 fixes this.

Still unsure if bpy.data.texts.load should do the same? Or is this expected to have zero users then?
(I included the fix for bpy.data.texts.load in D3447 as well...)

I think this has to do with commit blender/blender@a9163f7d22, blender/blender@646aa40cf7 (which only ensured real user for doing it from the UI?). Also see blender/blender@15eb83c8b3. Doing this from python [via `bpy.ops.text.open`] would skip this step because `SpaceText` as well as `PropertyPointerRNA` are not set in this case. Doing this from python [via `bpy.data.texts.load`] would also skip this. I **think** something like [D3447](https://archive.blender.org/developer/D3447) fixes this. Still unsure if `bpy.data.texts.load` should do the same? Or is this expected to have zero users then? (I included the fix for `bpy.data.texts.load` in [D3447](https://archive.blender.org/developer/D3447) as well...)

Am not totally happy with it, but looks like operators creating new datablocks usually ensure they have one user, even if not actually used… Image opening one e.g., which can probably generate some usercount inconsistency in some cases. So guess we can do that unconditionally for text opening op too.

RNA data.xxx.load funcs do not do that though, see data.images.load e.g.

Am not totally happy with it, but looks like operators creating new datablocks usually ensure they have one user, even if not actually used… Image opening one e.g., which can probably generate some usercount inconsistency in some cases. So guess we can do that unconditionally for text opening op too. RNA `data.xxx.load` funcs do not do that though, see `data.images.load` e.g.

This issue was referenced by blender/blender@7277f8973b

This issue was referenced by blender/blender@7277f8973b08f847685a39b9326fc1e2fb9e268b

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#55260
No description provided.