Skip to content

Fix QGIS crash on plugin initialization#1580

Merged
visr merged 2 commits intomainfrom
fix-qgis-crash
Jun 25, 2024
Merged

Fix QGIS crash on plugin initialization#1580
visr merged 2 commits intomainfrom
fix-qgis-crash

Conversation

@visr
Copy link
Member

@visr visr commented Jun 25, 2024

Fixes #993, by creating the column count first before setting their properties, and changing the index to 0 (0-based, first), since we now have only one column.

Based on the suggestion by @Huite in #993 (comment).
By repeatedly running pixi run test-ribasim-qgis-ui I am quite confident this fixes the issue. If I change the 0 back to 1 I got a crash again within a few tries.

@visr visr requested a review from Huite June 25, 2024 09:18
self.setHeaderLabels([""])
self.setHeaderHidden(False)
self.setColumnCount(1)
header = self.header()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need any header logic? There's only a single column, so there's no sections to speak of. The resizing behavior only matters for multiple columns too.

@@ -50,10 +50,10 @@ def __init__(self, parent: QWidget | None):
self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
self.setHeaderLabels([""])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to write " Layer" here as a label here? (Note the spaces in front, otherwise it looks too cramped...)

image

@Huite
Copy link
Contributor

Huite commented Jun 25, 2024

It makes sense that this fixes it (although still weird that doesn't just raises an exception).

I've approved, although take a look at my review comments -- since you're looking at this anyway.

@visr
Copy link
Member Author

visr commented Jun 25, 2024

Thanks, addressed comments in 7cd92b3.

Looks good now:

image

@visr visr merged commit 12c3f67 into main Jun 25, 2024
@visr visr deleted the fix-qgis-crash branch June 25, 2024 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ribasim_qgis crashes QGIS 3.34+

2 participants