title: PyQt5/qml app crashes when using python lock on a qml object
body: <p>i have a PyQt/qml app that crashes randomly and i cant figure why.</p>
  <p>environment:
  PyQt: 5.9.2
  python: 3.6.9
  ubuntu 18.04.6</p>
  <p>what im doing is:</p>
  <ul>
  <li>sending a dict to qml with a pyqtsignal</li>
  <li>adding an item to a ListModel thats built from this dict</li>
  <li>using model.get(0) to get this item back and send the model item to python side with a pyqtslot</li>
  <li>on python side saving this item in a dict {id: qml_object}</li>
  <li>update this qml item with setProperty()</li>
  <li>while im updating the qml object im using a python threading.lock around it so the same object wont be updated twice</li>
  </ul>
  <p>this process sometimes crashes with a segmentation fault and i dont understand why, i know its a weird way to implement it but i want to update the qml objects quickly and using setProperty from python side looks like the quickest way to go (instead of sending a signal to qml and search for the specific object)</p>
  <p>main.py</p>
  <pre><code>class MyApp(QApplication):
  def __init__(self):
      super(MyApp, self).__init__(sys.argv)
      self.manager = Manager()
      self._engine = QQmlApplicationEngine()
      self._engine.rootContext().setContextProperty(&quot;manager&quot;, self.Manager())
      self._engine.load(&quot;main.qml&quot;)
  </code></pre>
  <p>manager.py</p>
  <pre><code>class Manager(QObject):
  insertObject = pyqtSignal(QVariant, arguments=[&quot;dict&quot;])
  
  def __init__(self):
      QObject.__init__(self)
      self.qml_objects = {}
      self.lock = Lock()
      self.insertObject.emit({&quot;name&quot;: &quot;aaa&quot;})
  
  
  # something that triggers update_qml_object
  
  def update_qml_object(self, obj_id, name):
      with self.lock:
          self.qml_objects[obj_id].setProperty(&quot;name&quot;, name)
  
  @pyqtSlot(str, QVariant, name=&quot;setQmlObject&quot;)
  def set_event_qml_object(self, id, event_qml_obj):
      self.qml_objects[id] = event_qml_obj
  
  @pyqtSlot(str, QVariant, name=&quot;setQmlObject&quot;)
  def set_event_qml_object(self, id, event_qml_obj):
      self.qml_objects[id] = event_qml_obj
  </code></pre>
  <p>main.qml</p>
  <pre><code>ApplicationWindow {
  Item {
      ListModel {
          id: gridModel
          ...
      }
  
      listView{
          ....
      }
  
      Connections {
          target: manager
          onInsertObject: {
              addObj(dict)
          }
      }
  
      function addObj(obj) {
          model.add_item({&quot;name&quot;: obj.name})
          manager.setQmlObject(0, model.get(0))
      }
  }
  </code></pre>
  <p>}</p>