Solved Incorrect file structure


I'm having a recurring issue, opening a test project I was working on the previous day, I get the message "Incorrect file structure" and have to thrash the file. I'm starting to think I'm saving something wrong...

How can I debug file structure?
Does C4D generates any log when this happens?


Are you by any chance writing a plugin that writes to the C4D file? Read, Write, ReadObject, WriteObject etc...

@kbar I have some custom data types that use WriteData() and ReadData() to store data into the object's container, but haven't changed recently.

Hello Roger,

I think, @kbar's assumption is not too far fetched. But of course it's difficult to analyze from here.
Can you maybe break it down a bit and show us some of your code used in WriteData() and ReadData() (probably write is most interesting) in these custom data types?


Hello @a_block,

Turned out the corrupted files had nothing to do with my custom data. It started crashing on save, corrupting the project. I fixed the crashes by properly freeing vertex buffers with GlVertexBuffer::RemoveObject and GlProgramFactory::RemoveReference, just like the example. The save crash stopped and never again saw a corrupted file again.


Hi Roger,
that's good news!