Python: Modal operator's 'report' behaves differently when called from non-modal operator #48717

Closed
opened 2016-06-23 11:31:59 +02:00 by Sybren A. Stüvel · 8 comments

Blender Version
Broken: 2.77a and

Description of error
Calls to self.report() from the modal operator are not shown in the UI, when that modal operator is called from a non-modal operator. This makes it difficult to communicate with the user from long-running operators.

Furthermore, there is a difference in console output:
Modal operator called from space-menu:

  • only the last call to self.report() is shown on the console, after the operator has stopped running.

Modal operator called from non-modal operator:

  • all calls to self.report() are shown, after the operator has stopped running.

Exact steps for others to reproduce the error

  1. Open the attached blend file and run its script: test_nonmodal_calling_modal.blend

  2. Press SPACE in the 3d viewport (under the text editor) and choose 'Modal operator -- run me first'.

  3. See a self.report({'INFO'}) with decreasing counter appear four times, for counter=3, 2, 1, 0.

  4. Inspect the console output, and see that there are four log entries one second apart, and below that only one Info line from self.report({'INFO'}) with counter=0, which was printed after the modal operator was stopped.

  5. Press SPACE in the 3d viewport and choose 'Non-modal operator -- run me second'.

  6. Press the 'OK' button or hit Enter.

  7. See the self.report({'INFO'}) from the non-modal operator, but not from the modal operator it calls.

  8. Inspect the console output, and see that there are four log entries one second apart, and below that four Info lines from self.report({'INFO'}) with counter=3, 2, 1, 0, which were printed after the modal operator was stopped.

**Blender Version** Broken: 2.77a and **Description of error** Calls to `self.report()` from the modal operator are not shown in the UI, when that modal operator is called from a non-modal operator. This makes it difficult to communicate with the user from long-running operators. Furthermore, there is a difference in console output: Modal operator called from space-menu: - only the last call to self.report() is shown on the console, after the operator has stopped running. Modal operator called from non-modal operator: - all calls to self.report() are shown, after the operator has stopped running. **Exact steps for others to reproduce the error** 1. Open the attached blend file and run its script: [test_nonmodal_calling_modal.blend](https://archive.blender.org/developer/F318380/test_nonmodal_calling_modal.blend) 2. Press SPACE in the 3d viewport (under the text editor) and choose 'Modal operator -- run me first'. 3. See a `self.report({'INFO'})` with decreasing counter appear four times, for counter=3, 2, 1, 0. 4. Inspect the console output, and see that there are four log entries one second apart, and below that only one Info line from `self.report({'INFO'})` with counter=0, which was printed after the modal operator was stopped. 5. Press SPACE in the 3d viewport and choose 'Non-modal operator -- run me second'. 6. Press the 'OK' button or hit Enter. 7. See the `self.report({'INFO'})` from the non-modal operator, but **not** from the modal operator it calls. 8. Inspect the console output, and see that there are four log entries one second apart, and below that four Info lines from `self.report({'INFO'})` with counter=3, 2, 1, 0, which were printed after the modal operator was stopped.
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren
Sybren A. Stüvel self-assigned this 2016-06-23 11:33:21 +02:00
Sybren A. Stüvel removed their assignment 2016-06-23 11:42:35 +02:00

Added subscriber: @VukGardasevic

Added subscriber: @VukGardasevic
Bastien Montagne changed title from Modal operator behaves differently when called from non-modal operator to Python: Modal operator's 'report' behaves differently when called from non-modal operator 2016-06-24 21:52:19 +02:00
Campbell Barton was assigned by Bastien Montagne 2016-06-24 21:52:19 +02:00

Added subscriber: @mont29

Added subscriber: @mont29

Tried to understand follow that report thing this afternoon, with not much luck… In fact, I do not understand why the report of the first, directly called modal op works, since afaict python creates own report when calling an op, with RPT_OP_HOLD, which is supposed to prevent its drawing in header bar (see wm_operator_reports and wm_add_reports)…

Hopefully @ideasman42 will know better!

Tried to understand follow that report thing this afternoon, with not much luck… In fact, I do not understand *why* the report of the first, directly called modal op works, since afaict python creates own report when calling an op, with `RPT_OP_HOLD`, which is supposed to prevent its drawing in header bar (see `wm_operator_reports` and `wm_add_reports`)… Hopefully @ideasman42 will know better!

This issue was referenced by blender/blender@f1253f5d2b

This issue was referenced by blender/blender@f1253f5d2b710d4a3b3fcb4534007877a136702c

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author
Member

Awesome! Thanks for the quick fix :)

Awesome! Thanks for the quick fix :)
Sign in to join this conversation.
No Milestone
No project
No Assignees
5 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#48717
No description provided.