Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Use only selected features" un-check not working #270

Open
SavelevGeo opened this issue Oct 23, 2021 · 4 comments
Open

"Use only selected features" un-check not working #270

SavelevGeo opened this issue Oct 23, 2021 · 4 comments
Labels

Comments

@SavelevGeo
Copy link

SavelevGeo commented Oct 23, 2021

After checking "Use only selected features" in Plot parameters, then unchecking it, after selecting features in plot, other features are kicked out

Steps to reproduce the behavior:

  1. In the plot parameters check "Use only selected features"
  2. Apply it with update plot
  3. Uncheck "Use only selected features"
  4. Apply it with update plot
    --The plot is generated for all the features
  5. Select some features on graph or modify selection on map
  6. After auto-refresh the plot is updated as if the "Use only selected features" is checked

step 3

step 5

step 6 this is not zoom, this is whole graph

  • OS: Win10
  • QGIS 3.20.3
  • DataPlotly release 3.8.1
@SavelevGeo SavelevGeo added the bug label Oct 23, 2021
@ghtmtt
Copy link
Owner

ghtmtt commented Nov 2, 2021

confirmed, thanks for reporting. For the moment you have to clean the plot and recreate it from scratch

@jmonticolo
Copy link
Contributor

This bug is related to the signal selectionChanged connected to rebuild, see here.

The problem is that when the layer changes, or the "Use only selected features" checkbox is unchecked, the signal is still connected.

To resolve this, some solutions :

  • for every layer change or every new plot factory (when the layer is removed, the signal is killed with it deletion) : loop over all vector layer and try to disconnect the signal with an error handler
  • when the signal is connected to the layer, add a property to the layer object and for every layer change or every new plot factory : loop over all vector layer and disconnect the signal only for the layers with the signal
  • track every plot factories with their layers and connected states or not and disconnect layers when needed
  • create a new class that inherits from QgsVectorLayer to handle the signal connection / disconnection

IMHO, it's a bad idea to call self.source_layer.selection_changed.disconnect() without argument because some other codes, plugins can have signals connected.

@ghtmtt
Copy link
Owner

ghtmtt commented Apr 28, 2022

@jmonticolo thanks for the detailed report and for all the ideas. If you cannot provide a PR then I'll try to work on this issue in the next days

@jmonticolo
Copy link
Contributor

jmonticolo commented Apr 28, 2022

I can't provide a PR for the moment because I don't know where to go for keep it simple and complete.

Do you think to store a reference of rebuilt methods in a layer property when connected like :

self.source_layer.data_plotly_rebuilts = []
self.source_layer.data_plotly_rebuilts.append(self.rebuild)

is a good idea ?

and you can disconnect all rebuild methods if the layer has data_plotly_rebuilts property as long as this property has items. (I didn't try it for the moment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants