Maniphest T79182

window_manager.progress_end() does not refresh cursor
Closed, DuplicateBUG

Assigned To
None
Authored By
Mikhail Rachinskiy (alm)
Jul 23 2020, 7:58 AM
Tags
  • BF Blender
  • Python API
Subscribers
Borek Bures (spiv)
Germano Cavalcante (mano-wii)
Jeroen Bakker (jbakker)
Mikhail Rachinskiy (alm)
Philipp Oeser (lichtwerk)

Description

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce GTX 860M/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 436.48

Blender Version
Broken: version: 2.90.0 Alpha, branch: master, commit date: 2020-07-19 21:23, hash: rB78e40ad21f5b

Short description of error
window_manager.progress_end() does not refresh cursor, and it stays as black box until user moves cursor to a button or area border.
Here is how it looks, the cursor should refresh right after progress_end call, but it does not happen:

Exact steps for others to reproduce the error

  1. Open attached blend file.
  2. Place mouse cursor inside Text Editor area.
  3. Run script using Alt+P shortcut. (It won't work if you run it with button since button will refresh cursor after progress_end call.)
  4. The cursor will refresh only after window.cursor_set.

Event Timeline

Mikhail Rachinskiy (alm) created this task.Jul 23 2020, 7:58 AM
Germano Cavalcante (mano-wii) changed the task status from Needs Triage to Confirmed.Jul 23 2020, 3:49 PM
Germano Cavalcante (mano-wii) changed the subtype of this task from "Report" to "Bug".
Germano Cavalcante (mano-wii) added a project: Python API.
Germano Cavalcante (mano-wii) added a subscriber: Germano Cavalcante (mano-wii).

I can confirm.
Perhaps this function was not designed to run outside of a modal operator.

This would be a possible fix:

diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index 2af68956923..5bb9784b839 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -374,6 +374,9 @@ void WM_cursor_time(wmWindow *win, int nr)
   }
 
   window_set_custom_cursor(win, mask, bitmap, 7, 7);
+
+  /* Without this, cursor restore may fail. */
+  win->cursor = 0;
 }
 
 /**
Germano Cavalcante (mano-wii) updated the task description.Jul 23 2020, 3:51 PM
Jeroen Bakker (jbakker) added a subscriber: Jeroen Bakker (jbakker).Jul 28 2020, 1:23 PM
Borek Bures (spiv) added a subscriber: Borek Bures (spiv).Aug 22 2020, 12:06 PM

I confirm bug. Working in 2.83.5 and broken in 2.90.0 Beta.
I tried to use a modal operator, but it also doesn't work.
The Cursor is updated only when you move the mouse to another window.

class Progress(bpy.types.Operator):
    bl_label = "Progress Test"
    bl_idname = "op.progress"

    r_timer = None

    def invoke(self, context, event):
        wm = context.window_manager
        wm.progress_begin(0, 100)
        self.r_timer = context.window_manager.event_timer_add(0.1, window=context.window)
        context.window_manager.modal_handler_add(self)
        return {'RUNNING_MODAL'}
        
    def modal(self, context, event):
        wm = context.window_manager
        
        if event.type in {'LEFTMOUSE', 'RIGHTMOUSE', 'ESC'}:
            context.window_manager.event_timer_remove(self.r_timer)
            wm.progress_update(100)
            wm.progress_end()
            return {'CANCELLED'}

        if event.type == 'TIMER':                
            wm.progress_update(50)
            return {'RUNNING_MODAL'}

        return {'RUNNING_MODAL'}
    
def register():
    bpy.utils.register_class(Progress)
 
def unregister():
    bpy.utils.unregister_class(Pprogress)
 
if __name__ == "__main__":
    register()
Campbell Barton (campbellbarton) moved this task from Backlog to Bugs (UI) on the Python API board.Sep 15 2020, 9:19 AM
Philipp Oeser (lichtwerk) added a subscriber: Philipp Oeser (lichtwerk).Sep 15 2020, 9:30 AM