Toolbar - crash to desktop in edit mode when switching view with the navigation buttons

Reiner's picture
Project: 
Bforartists Tracker

The merge with Blender 2.78 has introduced a new bug. Crash to desktop when in edit mode, and trying to switch to another view with the toolbar buttons. This one didn't exist before the merge to 2.78.

Status: 
Closed (fixed)
Priority: 
Normal
Category: 
Bug report
Component: 
User interface
Assigned: 
Reporter: 
Created: 
Thu, 02/09/2017 - 11:00
Updated: 
Thu, 02/23/2017 - 08:38

Comments

27
Reiner's picture

Body: Old » New
Reiner's picture

Happens already with 2.78a. So it's something from the begin of the merge.

There is a console warning in the debug build, but it went too fast away. Needs deeper investigation.

Reiner's picture

Assigned: Unassigned » Reiner
Reiner's picture

Console warning is of no help here. Unfunny.

Image: 
Reiner's picture

Testscript works fine in Blender. This is definitely an issue with the port. We have killed something.

Reiner's picture

Not to catch yet.

Currently i am going with Meld through all files and the differences again. This approach is time consuming. But on the other hand, the merge has left quite a few code parts that should not longer exist or are currently not in Bforartists as they should. And so this step is also a necessary cleanup.

Reiner's picture

The test script ...

# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
 
 
import bpy
 
 
bl_info = {
    "name": "View Buttons",
    "author": "Reiner 'Tiles' Prokein",
    "version": (0, 0, 1),
    "blender": (2, 76, 0),
    "location": "",
    "description": "Adds a tab button row in the 3D View to switch between views",
    "warning": "",
    "wiki_url": "",
    "tracker_url": "",
    "category": "User Interface"}
 
 
class VIEW3D_MT_fromtop(bpy.types.Operator):
    """Change view to Top\nThis button is global, and changes all available 3D views\nUse the View menu to change the view just in selected 3d view"""
    bl_idname = "view3d.fromtop"
    bl_label = "view from top"
    bl_options = {'REGISTER', 'UNDO'}
 
    def execute(self, context): 
        for area in bpy.context.screen.areas:
            if area.type == 'VIEW_3D':
                override = bpy.context.copy()
                override['area'] = area
                bpy.ops.view3d.viewnumpad(override, type='TOP', align_active=False)
        return {'FINISHED'} 
 
class VIEW3D_MT_frombottom(bpy.types.Operator):
    """Change view to Bottom\nThis button is global, and changes all available 3D views\nUse the View menu to change the view just in selected 3d view"""
    bl_idname = "view3d.frombottom"
    bl_label = "view from bottom"
    bl_options = {'REGISTER', 'UNDO'}
 
    def execute(self, context):
        for area in bpy.context.screen.areas:
            if area.type == 'VIEW_3D':
                override = bpy.context.copy()
                override['area'] = area
                bpy.ops.view3d.viewnumpad(override, type='BOTTOM', align_active=False)
        return {'FINISHED'} 
 
class VIEW3D_MT_fromfront(bpy.types.Operator):
    """Change view to Front\nThis button is global, and changes all available 3D views\nUse the View menu to change the view just in selected 3d view"""
    bl_idname = "view3d.fromfront"
    bl_label = "view from front"
    bl_options = {'REGISTER', 'UNDO'}
    def execute(self, context):
 
        for area in bpy.context.screen.areas:
            if area.type == 'VIEW_3D':
                override = bpy.context.copy()
                override['area'] = area
                bpy.ops.view3d.viewnumpad(override, type='FRONT', align_active=False)
        return {'FINISHED'} 
 
class VIEW3D_MT_fromback(bpy.types.Operator):
    """Change view to Back\nThis button is global, and changes all available 3D views\nUse the View menu to change the view just in selected 3d view"""
    bl_idname = "view3d.fromback"
    bl_label = "view from back"
    bl_options = {'REGISTER', 'UNDO'}
 
    def execute(self, context):
        for area in bpy.context.screen.areas:
            if area.type == 'VIEW_3D':
                override = bpy.context.copy()
                override['area'] = area
                bpy.ops.view3d.viewnumpad(override, type='BACK', align_active=False)
        return {'FINISHED'} 
 
class VIEW3D_MT_fromleft(bpy.types.Operator):
    """Change view to Left\nThis button is global, and changes all available 3D views\nUse the View menu to change the view just in selected 3d view"""
    bl_idname = "view3d.fromleft"
    bl_label = "view from left"
    bl_options = {'REGISTER', 'UNDO'}
 
    def execute(self, context):
        for area in bpy.context.screen.areas:
            if area.type == 'VIEW_3D':
                override = bpy.context.copy()
                override['area'] = area
                bpy.ops.view3d.viewnumpad(override, type='LEFT', align_active=False)
        return {'FINISHED'} 
 
class VIEW3D_MT_fromright(bpy.types.Operator):
    """Change view to Right\nThis button is global, and changes all available 3D views\nUse the View menu to change the view just in selected 3d view"""
    bl_idname = "view3d.fromright"
    bl_label = "view from right"
    bl_options = {'REGISTER', 'UNDO'}
 
    def execute(self, context): 
        for area in bpy.context.screen.areas:
            if area.type == 'VIEW_3D':
                override = bpy.context.copy()
                override['area'] = area
                bpy.ops.view3d.viewnumpad(override, type='RIGHT', align_active=False)
        return {'FINISHED'} 
 
 
def view_buttons(self, context):
    layout = self.layout
 
    obj = context.active_object
    row = layout.row(align=True)
    #global custom_icons
 
    row = layout.row(align=True)
 
    row.operator("view3d.fromfront", text="front")
    row.operator("view3d.fromback", text="back")
    row.operator("view3d.fromleft", text="left")
    row.operator("view3d.fromright", text="right")
    row.operator("view3d.fromtop", text="top")
    row.operator("view3d.frombottom", text="bottom")
 
# global variable to store icons in
custom_icons = None
 
def register():
 
    bpy.utils.register_class(VIEW3D_MT_fromtop)
    bpy.utils.register_class(VIEW3D_MT_frombottom)
    bpy.utils.register_class(VIEW3D_MT_fromfront)
    bpy.utils.register_class(VIEW3D_MT_fromback)
    bpy.utils.register_class(VIEW3D_MT_fromleft)
    bpy.utils.register_class(VIEW3D_MT_fromright)
 
 
    bpy.types.INFO_HT_header.prepend(view_buttons) # Here we add our button in front of the View 3D header. 
 
 
 
 
def unregister():
 
    bpy.utils.unregister_class(VIEW3D_MT_fromtop)
    bpy.utils.unregister_class(VIEW3D_MT_frombottom)
    bpy.utils.unregister_class(VIEW3D_MT_fromfront)
    bpy.utils.unregister_class(VIEW3D_MT_fromback)
    bpy.utils.unregister_class(VIEW3D_MT_fromleft)
    bpy.utils.unregister_class(VIEW3D_MT_fromright)
 
# This allows you to run the script directly from blenders text editor
# to test the addon without having to install it.
 
if __name__ == "__main__":
    register()

 

Reiner's picture

Debuggin is of no help. At least not for me I-m so happy

Image: 
Reiner's picture

Body: Old » New
Reiner's picture

Very time consuming bug hunting since i always need to compile from scratch with running Cmake. So still at investigating.

The current hottest candidate is the startup file. Fingers crossed that i have really found the cause here.

Reiner's picture

The good news is i have catched the bug. It is the startup file. I have compiled with the Blender startup file, and the crash is gone.

The bad news is that some settings are gone now. The biggest issue here is that the Bforartists keymap has quit working after reimport. Seems that i have to redo it. And that's a biggie. Ah the fun ...

Reiner's picture

Redone the keymap from scratch. And the crash is back. Super frustrating. Must be a conflict in the keymap somewhere. Especially since delete and select has quit working.

So from scratch again with the keymap. And this time chapter by chapter with an eye when the crash bug appears.

Reiner's picture

One step further. Crash is gone. But still trouble with the hotkeys. And still no idea where the problem was. I guess i have removed the problem by simply redoing the keymap in little chunks.

The remaining problem zone is the switch between modes. The hotkeys for switching modes always messes up at the moment.

Reiner's picture

ROFL

Crash is back. And i have still no idea what it is \o/

Reiner's picture

blender.crash.txt:

# Blender 2.78 (sub 4), Unknown revision
bpy.ops.wm.splash()  # Operator
bpy.ops.mesh.primitive_cube_add(radius=1, view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))  # Operator
bpy.ops.mesh.primitive_cube_add(radius=1, view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))  # Operator
bpy.ops.object.editmode_toggle()  # Operator
bpy.ops.object.editmode_toggle()  # Operator
bpy.ops.object.mode_set(mode='EDIT')  # Operator
 
# backtrace
11: BLI_system_backtrace - 0x40DA2010
10: sig_handle_crash_backtrace - 0x3FA4CAE0
9: sig_handle_crash - 0x3FA4CB30
8: windows_exception_handler - 0x3FA4CD90
7: UnhandledExceptionFilter - 0x776BBAB0
6: EtwEventSetInformation - 0x777BE180
5: _C_specific_handler - 0x7775782C
4: RtlDecodePointer - 0x77767DE0
3: RtlUnwindEx - 0x77757910
2: KiUserExceptionDispatcher - 0x7778BA9A
1: memcpy - 0x4430ECD0
0: memcpy - 0x4430ECD0

 

Reiner's picture

Okay, it was really the startup file. The crash bug reappeared when i tried to save some time. I didn't want to redo the layouts from scratch. And loaded an old scene from 2.76 with *Load UI* on. And voila.

So it wasn't really the keymap. But something in the startup file. Which i still cannot nail. Can be everything that is stored there. But the formerly fixed bug when the scrollbars disappeared points towards a layout issue.

Redoing the keymap wasn't completely waste of time though. I had to reopen this chapter anyways. Since 2.78 brings new functionality and new hotkeys. Now it was just a bit more work than thought. And still is. But that's another issue.

For now i hope that i haven't forgotten too much stuff when redoing the keymap and the layouts and settings. And am simply happy that this bug is gone. Fingers crossed that it does not strike back!

Reiner's picture

Reiner's picture

Status: Active » Closed (fixed)
Reiner's picture

And the crash is back -.-

Reiner's picture

Status: Closed (fixed) » Needs work
Reiner's picture

Have it. And this time reproduceable. The last little thing i did was to turn on rotate around selection in the User Preferences. Then saved the startup file, and committed it with adding all the submodules.

When i turn off rotate around selection then all is fine. When i turn on rotate around selection then it crashes in edit mode with switching views.

Let's have a look if blender shows the same behaviour ...

... yes it does. And also just in edit mode like in Bforartists. But it's just my selfmade code that crashes blender here. Not the Blender classes. Nevertheless time for a bug report.

Image: 
Reiner's picture

Created a bug report in the blender bug tracker: https://developer.blender.org/T50733

Reiner's picture

Cannot wait for a miracle to happen. The development has to go on.

The bug is not to fix by me, that problem is above my heads. And it's not clear if and when the bug gets fixed by the blender developers. So we need another solution. Which is to disable the trouble code for now. And to solve the navigation issue in another way.

I have added an addon now to the 3D view header with the align view buttons. It uses the internal icons and the code from the view menu. Means it even shows the hotkeys. And the View toolbar is disabled in the standard layouts. I will reenable the trouble code in case the bug gets fixed.

I guess i will also create a blender version of the addon now. This solution isn't this bad.

Image: 
Reiner's picture

Reiner's picture

I was told that the cause is a wrong useage of BPY. My override method was wrong. Nevertheless interesting that the wrong soltuion worked until 2.77. And in all other modes but edit mode. But anyways. The important bit is that it works now. And i would have never found the problem here.

The solution:

def execute(self, context): 
        for area in bpy.context.screen.areas:
            if area.type == 'VIEW_3D':
                for region in area.regions:
                    if region.type == 'WINDOW':
                        override = bpy.context.copy()
                        override['area'] = area
                        override['region'] = region
                        bpy.ops.view3d.viewnumpad(override, type='TOP', align_active=False)
        return {'FINISHED'}

Many thanks for that.

Let's implement it.

 

 

Reiner's picture

Reiner's picture

Status: Needs work » Closed (fixed)