Material Preview and Scene properties

I have a question about material preview panel and python render addons.

The accepted way of writing a render exporter is to have a ‘render(self, scene)’ function and if the scene.name is ‘preview’, then preview is rendered. Renderer binary path is stored in a custom property attached to Scene, let’s call it render_engine.binary_path (scene.render_engine.binary_path), so the binary path is passed with the scene structure when render function is called. This property is saved with efutil.write_config_value to a config file.

While coding the exporter I usually clean all config from time to time to start with a default blender and this is where my question comes from. In a clean blender install, the binary path is not set and must be configured before using the external render. If you hit F12 or go to material panel, render doesn’t work, of course. After opening a clean blender, enabling the addon and setting up the binary path, render with F12 works but material panel doesn’t. Going to material panel triggers an error every time it tries to refresh the material preview as if the binary path was empty even if it has just been set. Only after closing blender and opening it again material preview works.

I guess it’s because the custom property binary_path has a default value loaded from addon config file using efutil.find_config_value but saved config does not exist on a clean install and the value is empty on the first run of blender. Only after the config file is created and blender reloaded the default value is set to the correct path.

It looks like preview scene passed to render function doesn’t have the same properties the main scene and only has the default values set, how can I update attributes on the preview scene or ensure that a changed property will be passed to the preview scene? Is this a bug in the way blender sends the preview scene struct to the addon when calling a render preview?