2
$\begingroup$

So I have been working on an exporter as part of my Google Summer of Code project. As I am new to Blender add-on development, I was under the impression that my code would get a clean slate every time it ran, specially when the register / unregister methods were implemented.

Unfortunately my code has been exhibiting some very weird behavior! It is basically as if all the data structures are being cached by the Python interpreter, and all code is being executed several times.

As GSOC projects are open source, you can check the source itself on Github, but it is far from complete yet.

All runs of the exporter produce a debug log with some of the operations carried out. It also helps convey my problem more precisely. Here's the successful output after a run on the default scene. Now here's the incomplete output on the second run of the same scene. Even though it crashes, it is clear that all lines are basically duplicated.

For the record, I am using vscode with this add-on for development. Please let me know if any more details are needed for this question!

$\endgroup$
8
  • $\begingroup$ I've taken a quick look and it seems you reload on every execution of the export operator. Perhaps this causes the problem? github.com/dwlsalmeida/ramses-blender/blob/… $\endgroup$
    – Robert Gützkow
    Jun 15 '19 at 19:42
  • $\begingroup$ Actually I have added this in an attempt to fix it, it sadly does not help nor break anything. $\endgroup$ Jun 15 '19 at 19:44
  • 1
    $\begingroup$ Not sure if I'll have time to investigate this further, but I would think you either happen to have a bug in reloading which results in two instances of RamsesExportOperator being registered or that some list isn't properly reset and you keep appending state which results in multiple executions when iterating over it. $\endgroup$
    – Robert Gützkow
    Jun 15 '19 at 20:09
  • $\begingroup$ IMO re-registering the addon is not the way to go. Executing an operator that is registered by the addon,that is unregistering and re-reregistering itself is confusing. Register it once.. Any property value you do not wish saved after running an operator use the bl_options = {'SKIP_SAVE'} to return to defaults on next run. $\endgroup$
    – batFINGER
    Jun 16 '19 at 12:19
  • $\begingroup$ If I comment that line nothing changes. See someone with the same issue blender.stackexchange.com/questions/46990/… $\endgroup$ Jun 16 '19 at 13:03
0
$\begingroup$

EDIT: Actually, my implementation was broken, but thanks for all the help given in this thread!

$\endgroup$
1
  • 2
    $\begingroup$ This looks wrong. My advice: Create a minimal working example were you can still see the bug happening, but all the task specific logic isn't in there. Check under which conditions the double execution happens. Check the data structures that are involved. Narrow it down to a specific line. If that doesn't help compare your code with the ones of existing add-ons. See where there are differences in the basic setup of the add-on. $\endgroup$
    – Robert Gützkow
    Jun 17 '19 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.