SOLVED def state breaks viewport rendering when script is docked in layout

I encounter a problem when creating a Python script, and docking that script into the layout.
I have simplified the script as much as possible, by simple generating a new script from the Script Manager, and enabled the commented out "def state():" function as such

import c4d
from c4d import gui
# Welcome to the world of Python


# Script state in the menu or the command palette
# Return True or c4d.CMD_ENABLED to enable, False or 0 to disable
# Alternatively return c4d.CMD_ENABLED|c4d.CMD_VALUE to enable and check/mark
def state():
    return True

# Main function
def main():
    gui.MessageDialog('Hello World!')

# Execute main()
if __name__=='__main__':
    main()

When you save this script, and add the script icon into your layout, then rendering to viewport is broken.
Sometimes pressing the "render view" button simply does not react (same with shortcut Ctrl-R), sometimes the command reacts but generates a black render.

Open the script, put the "def state():" function in comment, save, and rendering is reacting as should be.

Haven't tried on other version of Cinema4D, but people have responded that this issue is present in R21 and up (at least on Windows, haven't tried on macOS)

I have tried returning True, False, CMD_ENABLED, CMD_ENABLED | CMD_VALUE ...
I even have tried without any return at all.
Same result: as soon as "def state():" is present in the script, and script's icon is added to a palette in the layout -> render view is broken

Hi @C4DS thanks for your report.

The issue is within the implementation of the GetState call of a Python Script so nothing you could fix in your own. I made a bug report and a fix will be provided in an upcoming version.

One side note could you please mark your next topic as a question as described in the Forum Guideline. I did it but would be really nice if you could do it the next time 🙂 I also did set it as resolved since the bug is logged in our internal system and just waiting for the bugfix to be delivered, that's why I added the Tag "To Fix" to your topic, so I will bump your topic once the fix is released.

Cheers,
Maxime.

@m_adam
Thanks for the reply.
I did mark the post as a question. But didn't see any difference.

I also still don't see any notification, (notification bell remains unchanged), even though there are new notifications when I press the bell icon.
Using Firefox (94.0.1 = latest version).
No big deal, but it might be related to the failed mark-post-as-question.