mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
adding a lock for the create snapshot
CURA-11650
This commit is contained in:
parent
9ded56c54f
commit
e905ac9d33
1 changed files with 4 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
import json
|
||||
import re
|
||||
import threading
|
||||
|
||||
from typing import Optional, cast, List, Dict, Pattern, Set
|
||||
|
||||
|
@ -65,6 +66,7 @@ class ThreeMFWriter(MeshWriter):
|
|||
self._unit_matrix_string = ThreeMFWriter._convertMatrixToString(Matrix())
|
||||
self._archive: Optional[zipfile.ZipFile] = None
|
||||
self._store_archive = False
|
||||
self._lock = threading.Lock()
|
||||
|
||||
@staticmethod
|
||||
def _convertMatrixToString(matrix):
|
||||
|
@ -423,6 +425,7 @@ class ThreeMFWriter(MeshWriter):
|
|||
@call_on_qt_thread # must be called from the main thread because of OpenGL
|
||||
def _createSnapshot(self):
|
||||
Logger.log("d", "Creating thumbnail image...")
|
||||
self._lock.aquire()
|
||||
if not CuraApplication.getInstance().isVisible:
|
||||
Logger.log("w", "Can't create snapshot when renderer not initialized.")
|
||||
return None
|
||||
|
@ -431,6 +434,7 @@ class ThreeMFWriter(MeshWriter):
|
|||
except:
|
||||
Logger.logException("w", "Failed to create snapshot image")
|
||||
return None
|
||||
finally: self._lock.release()
|
||||
|
||||
return snapshot
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue