Hotkey uninstall issue - Search for unknown operator ...

I work at a plugin. I get two Search for unknown operator … warnings in the console every time i uninstall my plugin. First i thought i do something wrong. But this happens also with other plugins as i have noticed. It has definitely to do with the hotkey. When i leave the hotkey away then i don’t get a warning.

It doesn’t really harm. The plugin uninstalls clean even with the two messages. The user might not even notice it. But it doesn’t really look nice. And i am interested in what it is and how to remove this.

Where does those two messages come from? There is only one hotkey to remove. So even the number of warnings is odd. Is this a known issue? Any ideas here?

Here’s my code, which is also a good testplugin to test the issue with:


bl_info = {
    "name": "Create Testpanel",
    "description": "Creates a testpanel",
    "author": "Reiner 'Tiles' Prokein",
    "version": (0, 7),
    "blender": (2, 69, 0),
    "location": "Toolshelf",
    "warning": "", # used for warning icon and text in addons panel
    ## not yet ...
#    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"
#                "Scripts/createisocam",
    "category": "Create"}


import bpy

# ----------------------------------------- Create a ground plane
class creategroundplane(bpy.types.Operator):
    """Creates a groundplane in size of ten where you can put your things on"""
    bl_idname = "scene.create_groundplane"
    bl_label = "Groundplane"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        bpy.ops.mesh.primitive_plane_add(location=(0, 0, 0)) # Create Camera. I would love to set the scale here too. Blender not. So let's do it in an extra step 

        object = bpy.context.scene.objects.active
        object.scale = (5, 5, 0)#The plane object is created with a size of 2. Scaling it to 10 means to scale it by factor 5
        bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)# apply scale

        return {'FINISHED'}   
    
#----------------------------------------- Create panel in the toolshelf -------------------------------------------------

class Createtestpanel(bpy.types.Panel):
    bl_label = "Create Testpanel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"
    bl_category = "Testpanel"

    def draw(self, context):
        

        layout = self.layout
        view = context.space_data
        
        col = layout.column(align=True)
        col.operator("scene.create_groundplane", text="Groundplane")
# -------------------------------------------------------------------------------------------

# store keymaps here to access after registration
addon_keymaps = []
   

def register():
    bpy.utils.register_class(creategroundplane)
    bpy.utils.register_class(Createtestpanel)

        # handle the keymap
    wm = bpy.context.window_manager
    km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')

    kmi = km.keymap_items.new(creategroundplane.bl_idname, 'SPACE', 'PRESS', ctrl=True, shift=True)

    addon_keymaps.append(km)

def unregister():
    bpy.utils.unregister_class(creategroundplane)
    bpy.utils.unregister_class(Createtestpanel)

        # handle the keymap
    wm = bpy.context.window_manager
    for km in addon_keymaps:
        wm.keyconfigs.addon.keymaps.remove(km)
    # clear the list
    del addon_keymaps[:]


if __name__ == "__main__":
    register()
            
            
            

Attachments


I’ve used this one that i copied from somewhere, it seems to work:

register:

keyMap = bpy.context.window_manager.keyconfigs.active.keymaps['3D View']
keyMapItem = keyMap.keymap_items.new('view3d.modal_pc_click_dof', 'D', 'PRESS')

unregister:

keyMapItems = bpy.context.window_manager.keyconfigs.active.keymaps['3D View'].keymap_items
    for keyMapItem in keyMapItems:
        if keyMapItem.idname == 'wm.call_menu' and keyMapItem.properties.name == "VIEW3D_Physical_Camera_click_DOF":
            keyMapItems.remove(keyMapItem)
            break

Thanks bashi, will give it a try :slight_smile:

The funny thing is that my code comes from the official addon tutorial. So there seems to be a need to fix something … http://www.blender.org/documentation/blender_python_api_2_65_5/info_tutorial_addon.html

Hmmmm! I tried your method, and now i get four messages at uninstall instead of two :slight_smile:

Then let there be warnings, and i release my script with them. They doesn’t really harm. Thanks for your help :slight_smile:

Did you fix that? i’m getting the same problem here