Skip to content

Commit

Permalink
Deepcopy settings when creating factories (#356)
Browse files Browse the repository at this point in the history
* Deepcopy settings when creating factories

Otherwise things get murky when we re-use the same settings
objects with multiple factories, as the factory plot
generation logic modifies settings (eg by recording
the list of found feature ids)

Fixes incomplete plots when used with atlas

* Simpler fix
  • Loading branch information
nyalldawson authored Oct 24, 2024
1 parent 7ab2553 commit 4319fbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 5 additions & 3 deletions DataPlotly/core/plot_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
(at your option) any later version.
"""


import tempfile
import os
import re
import plotly
import plotly.graph_objs as go
from copy import deepcopy
from plotly import subplots

from qgis.core import (
Expand Down Expand Up @@ -95,9 +97,9 @@ def __init__(self, settings: PlotSettings = None, context_generator: QgsExpressi
visible_region: QgsReferencedRectangle = None, polygon_filter: FilterRegion = None):
super().__init__()
if settings is None:
settings = PlotSettings('scatter')

self.settings = settings
self.settings = PlotSettings('scatter')
else:
self.settings = deepcopy(settings)
self.context_generator = context_generator
self.raw_plot = None
self.plot_path = None
Expand Down
5 changes: 5 additions & 0 deletions DataPlotly/core/plot_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
(at your option) any later version.
"""

from copy import deepcopy
from qgis.PyQt.QtCore import QFile, QIODevice
from qgis.PyQt.QtXml import QDomDocument, QDomElement
from qgis.core import QgsXmlUtils, QgsPropertyCollection, QgsPropertyDefinition

def _pc_deepcopy(self, memo):
return QgsPropertyCollection(self)

QgsPropertyCollection.__deepcopy__ = _pc_deepcopy

class PlotSettings: # pylint: disable=too-many-instance-attributes
"""
Expand Down

0 comments on commit 4319fbc

Please sign in to comment.