Skip to content

Commit

Permalink
Workaround crash on mac platform with non-default themes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 25, 2023
1 parent b426928 commit 49f1287
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
6 changes: 3 additions & 3 deletions koordinates/gui/date_filter_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
QSizePolicy
)
from qgis.gui import (
QgsRangeSlider,
QgsDateEdit
)

from .filter_widget_combo_base import FilterWidgetComboBase
from ..api import DataBrowserQuery
from .range_slider import RangeSlider

DATE_FORMAT = 'dd MMM yyyy'

Expand Down Expand Up @@ -66,7 +66,7 @@ def __init__(self, parent):
published_date_label.setFont(bold_font)
vl.addWidget(published_date_label)

self.published_date_slider = QgsRangeSlider()
self.published_date_slider = RangeSlider()
self.published_date_slider.setMinimumHeight(self.fontMetrics().height())
vl.addWidget(self.published_date_slider)

Expand Down Expand Up @@ -94,7 +94,7 @@ def __init__(self, parent):
updated_date_label.setFont(bold_font)
vl.addWidget(updated_date_label)

self.updated_date_slider = QgsRangeSlider()
self.updated_date_slider = RangeSlider()
self.updated_date_slider.setMinimumHeight(self.fontMetrics().height())
vl.addWidget(self.updated_date_slider)

Expand Down
20 changes: 20 additions & 0 deletions koordinates/gui/range_slider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import platform
from qgis.PyQt.QtCore import QSize
from qgis.gui import QgsRangeSlider


class RangeSlider(QgsRangeSlider):
"""
Avoids a crash when non-standard application themes are used on the
mac platform.
Relates to https://bugreports.qt.io/browse/QTBUG-43398
https://bugreports.qt.io/browse/QTBUG-44316?focusedCommentId=272257
"""

def sizeHint(self):
if platform.system() == 'Darwin':
# sizeHint crashes on mac for hidden QSlider widgets
return QSize(100, 30)

return super().sizeHint()
4 changes: 2 additions & 2 deletions koordinates/gui/resolution_filter_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
QHBoxLayout,
QLabel
)
from qgis.gui import QgsRangeSlider

from .filter_widget_combo_base import FilterWidgetComboBase
from ..api import DataBrowserQuery
from .range_slider import RangeSlider


class ResolutionFilterWidget(FilterWidgetComboBase):
Expand All @@ -22,7 +22,7 @@ def __init__(self, parent):

self.drop_down_widget = QWidget()
vl = QVBoxLayout()
self.slider = QgsRangeSlider()
self.slider = RangeSlider()
self.slider.setMinimumHeight(self.fontMetrics().height())
vl.addWidget(self.slider)

Expand Down

0 comments on commit 49f1287

Please sign in to comment.