Page MenuHome

Class naming issue
Closed, ResolvedPublic

Description

System Information
Operating system: Darwin-15.6.0-x86_64-i386-64bit 64 Bits
Graphics card: ATI Radeon HD 5770 OpenGL Engine ATI Technologies Inc. 4.1 ATI-1.42.15

Blender Version
Broken: version: 2.81 (sub 2), branch: master, commit date: 2019-08-19 19:05, hash: rB74d05eb71a0d
Worked: (optional)

Short description of error
With 2.80 comes the better method of naming classes, this should prevent accidental registering class with same name. On [[ https://wiki.blender.org/wiki/Reference/Release_Notes/2.80/Python_API/Addons | this page ]]there are examples given, yet one example is false and will return error.
It shows this example

**Valid Examples:**
class OBJECT_OT_fancy_tool (and bl_idname = "object.fancy_tool")

Exact steps for others to reproduce the error
01. Name class ADDON_OT_OperatorName
02. give addon bl_idname a name "addon.ot_operator_name
03. Activate addon, it will return an error stating Prefix & Suffix issue"

Details

Type
Bug

Event Timeline

Brecht Van Lommel (brecht) triaged this task as Needs Information from User priority.

Please provide a Python script to reproduce the problem.

Yes sorry for missing file. Ive tried adding the minimal parts need to reproduce this. Prior this would work when only the Class header had _MT_ in it. I think since release candidate 1 or 2 it stopped. Until yesterday i didn't looked at it. but had to since i wanted to update an addon. I noticed that now the bl_idname also needs _MT_ in it properly. Yet operators still work using say qs.quick_switch.

In the link in the first post its not very clear that the bl_idname also needs proper naming. The example even shows a version like the added blend file.

Hope this is more clear like this

Just hit Run Script and check the console
This is the error i get

register_class(...):
Warning: 'qs.quick_switch_menu' doesn't contain '_MT_' with prefix & suffix
Info: Saved "prefix_suffix_error.blend"

Brecht Van Lommel (brecht) raised the priority of this task from Needs Information from User to Needs Triage by Developer.Thu, Aug 22, 5:47 PM
Brendon Murphy (meta-androcto) closed this task as Resolved.

hi, this is a fairly normal warning, in your file you have the bl_idname wrong

bl_idname = "QS_MT_quick_switch_menu"

would be better. This will fix the prefix, suffix error.
As for your 2nd question, bl_idname is not needed for menus iirc. It can be used but not needed so that's why it was working.

I understand, but this worked in release candidates and prior. I did not see any info that bl_idname for menus explicitly needs _mt_ in the idname as well. That's not quite clear on the info page