koordinates / kart-qgis-plugin

A QGIS integration plugin for Kart repositories. Distributed version-control for geospatial and tabular data.
https://kartproject.org
GNU General Public License v2.0
36 stars 16 forks source link

Error occurred when using "Swipe" diff type to show the changes #110

Open elinaw123 opened 2 months ago

elinaw123 commented 2 months ago

Describe the bug An error occurred when using "Swipe" diff type to show the changes under the "Geometries" tab.

To Reproduce Steps to reproduce the behavior:

  1. Import a point layer from PostGIS
  2. Add one extra point
  3. Select "Show working copy changes for this dataset..."
  4. See error

Expected behavior I expected to see the before and after changes in a split window.

Screenshots

image

Version info (this is important!): Kart Plugin version 1.0.14 QGIS version 3.34.6-Prizren Operating system Windows 11 10.0.22631 SP0 Kart version Kart v0.15.2, Copyright (c) Kart Contributors » GDAL v3.8.5; PROJ v9.4.0; PDAL v2.6.0 » PyGit2 v1.12.1; Libgit2 v1.6.4; Git v2.45.1.7.g5be46a8262; Git LFS v3.3.0 » SQLAlchemy v1.4.45; pysqlite3 v2.6.0/v3.45.3; SpatiaLite v5.1.0; Libpq v16.0.2

jakimowb commented 1 week ago

I can reproduce the bug (appeared during workshop on QGIS UC 2024). After closing the error dialog it will pop-up again, forcing users to kill the entire QGIS instance.

kannes commented 1 week ago

As a blind bruteforce fix you can replace the paint function in gui/swipemap.py with this:

    def paint(self, painter, *args):  # NEED *args for WINDOWS!
        if len(self.layers) == 0 or self.length == -1 or self.image is None:
            return

        if self.isVertical:
            h = self.image.height() - 2
            w = self.length
            line = QLine(int(w) - 1, 0, int(w) - 1, int(h) - 1)
        else:
            h = self.image.height() - self.length
            w = self.image.width() - 2
            line = QLine(0, int(h) - 1, int(w) - 1, int(h) - 1)

        image = self.image.copy(0, 0, int(w), int(h))
        painter.drawImage(QRect(0, 0, int(w), int(h)), image)
        painter.drawLine(line)