mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 15:57:52 -06:00
Don't reset zeroconf until after (most) printers have been found
CURA-2060
This commit is contained in:
parent
fb371f5556
commit
1ed3fc7c37
1 changed files with 5 additions and 5 deletions
|
@ -27,8 +27,8 @@ class DiscoverUM3Action(MachineAction):
|
||||||
|
|
||||||
Application.getInstance().engineCreatedSignal.connect(self._createAdditionalComponentsView)
|
Application.getInstance().engineCreatedSignal.connect(self._createAdditionalComponentsView)
|
||||||
|
|
||||||
self._min_time_between_restart_discovery = 1
|
self._last_zeroconf_event_time = time.time()
|
||||||
self._time_since_last_discovery = time.time() - self._min_time_between_restart_discovery
|
self._zeroconf_change_grace_period = 0.25 # Time to wait after a zeroconf service change before allowing a zeroconf reset
|
||||||
|
|
||||||
printersChanged = pyqtSignal()
|
printersChanged = pyqtSignal()
|
||||||
|
|
||||||
|
@ -41,19 +41,19 @@ class DiscoverUM3Action(MachineAction):
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def restartDiscovery(self):
|
def restartDiscovery(self):
|
||||||
# Ensure that there is a bit of time between refresh attempts.
|
# Ensure that there is a bit of time after a printer has been discovered.
|
||||||
# This is a work around for an issue with Qt 5.5.1 up to Qt 5.7 which can segfault if we do this too often.
|
# This is a work around for an issue with Qt 5.5.1 up to Qt 5.7 which can segfault if we do this too often.
|
||||||
# It's most likely that the QML engine is still creating delegates, where the python side already deleted or
|
# It's most likely that the QML engine is still creating delegates, where the python side already deleted or
|
||||||
# garbage collected the data.
|
# garbage collected the data.
|
||||||
# Whatever the case, waiting a bit ensures that it doesn't crash.
|
# Whatever the case, waiting a bit ensures that it doesn't crash.
|
||||||
if time.time() - self._time_since_last_discovery > self._min_time_between_restart_discovery:
|
if time.time() - self._last_zeroconf_event_time > self._zeroconf_change_grace_period:
|
||||||
if not self._network_plugin:
|
if not self._network_plugin:
|
||||||
self.startDiscovery()
|
self.startDiscovery()
|
||||||
else:
|
else:
|
||||||
self._network_plugin.startDiscovery()
|
self._network_plugin.startDiscovery()
|
||||||
self._time_since_last_discovery = time.time()
|
|
||||||
|
|
||||||
def _onPrinterDiscoveryChanged(self, *args):
|
def _onPrinterDiscoveryChanged(self, *args):
|
||||||
|
self._last_zeroconf_event_time = time.time()
|
||||||
self.printersChanged.emit()
|
self.printersChanged.emit()
|
||||||
|
|
||||||
@pyqtProperty("QVariantList", notify = printersChanged)
|
@pyqtProperty("QVariantList", notify = printersChanged)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue