Move _error_check_timer initialization to a separate function

This simplifies understanding the class __init__ function
This commit is contained in:
digitalfrost 2022-08-02 08:30:08 +02:00
parent a7b1052b27
commit b13b7a892d

View file

@ -45,16 +45,12 @@ class MachineErrorChecker(QObject):
self._start_time = 0. # measure checking time
# This timer delays the starting of error check so we can react less frequently if the user is frequently
# changing settings.
self._error_check_timer = QTimer(self)
self._error_check_timer.setInterval(100)
self._error_check_timer.setSingleShot(True)
self._setCheckTimer()
self._keys_to_check = set() # type: Set[str]
self._num_keys_to_check_per_update = 10
def initialize(self) -> None:
self._error_check_timer.timeout.connect(self._rescheduleCheck)
@ -66,6 +62,18 @@ class MachineErrorChecker(QObject):
self._onMachineChanged()
def _setCheckTimer(self) -> None:
"""A QTimer to regulate error check frequency
This timer delays the starting of error check
so we can react less frequently if the user is frequently
changing settings.
"""
self._error_check_timer = QTimer(self)
self._error_check_timer.setInterval(100)
self._error_check_timer.setSingleShot(True)
def _onMachineChanged(self) -> None:
if self._global_stack:
self._global_stack.propertyChanged.disconnect(self.startErrorCheckPropertyChanged)