CRITICAL: Stop when calling SetWorldPluginData
-
Hi,
I'm developing a Python plugin on Win with C4D 2023.2.0 / 2023.CL399467.5638.
The question is, what does it mean, if i get "CRITICAL: Stop [btree_container.cpp(2551)]" in debug console, when calling
c4d.plugins.SetWorldPluginData()
?At first I thought, it was related to me stupidly trying to call
c4d.plugins.SetWorldPluginData()
from a thread. But after fixing this, I now get this on the main thread, too. I double checked, that the types when accessing the containers are correct (I mean, when writing into or reading from my own plugin's "world container").
Pretty sure, I overlooked something stupid, therefore I hope any hint on what may cause above critical stop will point me into thee right direction.Thanks in advance,
Andreas -
Hey @a_block,
Thank you for reaching out to us. This is the section of code that throws your error:
This code at this location is unique to
2023.2
in prior versions that code was at a substantially different line number in the same file, and in the current beta build the filebtree_container.cpp
does not exist anymore, and the function containing this code has moved to another file and shrunken from 129 lines of code to 14 (sic!) lines of code. I.e., things are in motion here.The method is concerned with copying data between two data containers. The error is being raised when two
GeData
which shall be copied carry the same pointer valueDContainer
.Without your concrete code, I cannot do much more than guess what is going wrong there for you. I also gave the function
SetWorldPluginData
and its reading counterpartGetWorldPluginData
a spin, without having any problems. See end of the posting for my code.Cheers,
FerdinandResult for running the script four times in a row in a Cinema 4D installation where the script has never run before. I ran the code successfully both with:
- 2023.2.0 (Build 2023.CL399467.56383) Win
- 2023.2.1 (Build 2023.CL401745.844493561) Win
---------------------------------------------------------------------------------------------------- key = 1000, value = 42 key = 1001, value = 3.1415 key = 1002, value = <c4d.SplineData object at 0x000002575F960A40> key = 1413, value = '.Djlq;_u;v<-\\T:5+Uu(' ---------------------------------------------------------------------------------------------------- key = 1000, value = 42 key = 1001, value = 3.1415 key = 1002, value = <c4d.SplineData object at 0x000002575F944740> key = 1413, value = '.Djlq;_u;v<-\\T:5+Uu(' key = 1292, value = "K`'2%0[oIjWgg^^trE{j" ---------------------------------------------------------------------------------------------------- key = 1000, value = 42 key = 1001, value = 3.1415 key = 1002, value = <c4d.SplineData object at 0x000002575F94A940> key = 1413, value = '.Djlq;_u;v<-\\T:5+Uu(' key = 1292, value = "K`'2%0[oIjWgg^^trE{j" key = 1850, value = 'l7#z*a=%nAyaNJH2aCoQ' ---------------------------------------------------------------------------------------------------- key = 1000, value = 42 key = 1001, value = 3.1415 key = 1002, value = <c4d.SplineData object at 0x000002575F947540> key = 1413, value = '.Djlq;_u;v<-\\T:5+Uu(' key = 1292, value = "K`'2%0[oIjWgg^^trE{j" key = 1850, value = 'l7#z*a=%nAyaNJH2aCoQ' key = 1041, value = 'ZESmFH}bp-KQo3jth)*A'
Code:
"""Demonstrates the usage of #GetWorldPluginData and #SetWorldPluginData to read and write data persistently from/into the application data container. Run this script multiple times in a row in the script manager to see data accumulate under the ID ID_PLUGIN_SETPLUGINDATA. """ import c4d import random doc: c4d.documents.BaseDocument op: c4d.BaseObject | None # It is obviously important that you store data under a unique plugin ID. ID_PLUGIN_SETPLUGINDATA: int = 1061159 def main() -> None: """Writes and reads data under the ID #ID_PLUGIN_SETPLUGINDATA into the application data container. """ data: c4d.BaseContainer = c4d.BaseContainer(ID_PLUGIN_SETPLUGINDATA) # Write data with both the __setitem__ Python interface and the native C++ methods. data[1000] = 42 data.SetFloat(1001, 3.1415) # Since the bug seems to be related to GeData, write custom data type data. If I had to guess, # your problem likely is stemming from something like this. Maybe you are trying to write the # same custom data type instance twice or something like that, which results then in the failed # pointer comparison? You could try using a copy constructor then to copy data. spline: c4d.SplineData = c4d.SplineData() spline.MakeSinSpline(36) data.SetData(1002, spline) # Write data at a random location so that we can test the container merging. data[random.randint(1003, 2000)] = "".join((chr (random.randint(33, 126)) for _ in range(20))) # Write the data, the last argument #add sounds a bit like it could be the triggering factor, # as it determines if #data is merged with the container at #ID_PLUGIN_SETPLUGINDATA or # overwrites it. But both #True and #False work fine for me. if not c4d.plugins.SetWorldPluginData(ID_PLUGIN_SETPLUGINDATA, data, add=True): raise RuntimeError(f"Could not store plugin data under id: {ID_PLUGIN_SETPLUGINDATA}.") # Read the data back. _data: c4d.BaseContainer = c4d.plugins.GetWorldPluginData(ID_PLUGIN_SETPLUGINDATA) if not _data: raise RuntimeError(f"Could not read plugin data under id: {ID_PLUGIN_SETPLUGINDATA}.") print("\n", "-" * 100) for key, value in _data: print(f"{key = }, {value = }") if __name__ == '__main__': main()
-
Thanks so much, Ferdinand.
This helped me a lot and also this message being changed in 2023.2 explains a lot for me.Unfortunately at the current point I am not in a position to make any of our code public. In consequence there is little to learn here for other readers. Sorry!
-
Hey @a_block,
sure, no worries. I am sure you are aware, but as a reminder, you can share code confidentially with us in case you run into a brick wall.
Cheers,
Ferdinand -
Thanks for the offer. much appreciated. But your explanations were good and plenty as usual.
I think, I know exactly what is going on.