Bug: Print layout exports wrong map theme when using "Follow Map Theme"
<<I am not a coder - this is what claude exported. I spent the evening trying to fix this, and this fix finally worked after about ten different failed attempts>>
When exporting print layouts using Maps Printer, if a layout's map item is set to "Follow Map Theme", the export uses the active canvas theme instead of the theme linked to the layout. This means all layouts export with the same theme rather than their individually assigned themes.
This affects layouts with one or two map frames, and is especially noticeable when frames use entirely different layer sets per theme.
Fix: Before exporting each layout, iterate through its map items one at a time. For each map item that has "Follow Map Theme" set, apply that specific item's linked theme to the global layer tree via applyTheme(), then immediately force just that map item to invalidate its cache and re-render against the now-correct global layer tree state — before moving on to the next map item. This is critical: if you apply all themes first and re-render after, or apply a single theme for the whole layout, it doesn't work. Each item must be applied and pre-rendered in sequence so its cached image is locked in before the global layer tree changes for the next item. By the time the exporter runs, every frame already has the correct image cached and the exporter uses those cached images rather than re-reading the global layer tree. The global layer tree and canvas theme are then restored to their original state via a try/finally block.
The critical detail is calling item.invalidateCache() and item.updateBoundingRect() immediately after each applyTheme() call — this pre-renders each frame against the correct theme before the exporter fires.
The fix is in processor.py inside exportCompo(). the patched file is attached.
processor_patched.py
Bug: Print layout exports wrong map theme when using "Follow Map Theme"
<<I am not a coder - this is what claude exported. I spent the evening trying to fix this, and this fix finally worked after about ten different failed attempts>>
When exporting print layouts using Maps Printer, if a layout's map item is set to "Follow Map Theme", the export uses the active canvas theme instead of the theme linked to the layout. This means all layouts export with the same theme rather than their individually assigned themes.
This affects layouts with one or two map frames, and is especially noticeable when frames use entirely different layer sets per theme.
Fix: Before exporting each layout, iterate through its map items one at a time. For each map item that has "Follow Map Theme" set, apply that specific item's linked theme to the global layer tree via applyTheme(), then immediately force just that map item to invalidate its cache and re-render against the now-correct global layer tree state — before moving on to the next map item. This is critical: if you apply all themes first and re-render after, or apply a single theme for the whole layout, it doesn't work. Each item must be applied and pre-rendered in sequence so its cached image is locked in before the global layer tree changes for the next item. By the time the exporter runs, every frame already has the correct image cached and the exporter uses those cached images rather than re-reading the global layer tree. The global layer tree and canvas theme are then restored to their original state via a try/finally block.
The critical detail is calling item.invalidateCache() and item.updateBoundingRect() immediately after each applyTheme() call — this pre-renders each frame against the correct theme before the exporter fires.
The fix is in processor.py inside exportCompo(). the patched file is attached.
processor_patched.py