def testNonCppWrapperClassDelete(self): """Would segfault when shiboken.delete called on obj not created from Python """ obj = sample.ObjectType() child = obj.createChild(None) shiboken.delete(child) assert not shiboken.isValid(child)
def testDelete(self): obj = ObjectType() child = ObjectType(obj) self.assertTrue(shiboken.isValid(obj)) self.assertTrue(shiboken.isValid(child)) # Note: this test doesn't assure that the object dtor was really called shiboken.delete(obj) self.assertFalse(shiboken.isValid(obj)) self.assertFalse(shiboken.isValid(child))
def testClassDecref(self): # Bug was that class PyTypeObject wasn't decrefed when instance died before = sys.getrefcount(ObjectType) for i in range(1000): obj = ObjectType() shiboken.delete(obj) after = sys.getrefcount(ObjectType) self.assertLess(abs(before - after), 5)
def deleteConnectionWidget(self, port): # Delete Connection from System self._system.deleteConnection(port) self.commit() # Delete Connection Widget widget = self._connectionWidgets.pop(port) self.uiConnectionsLAY.removeWidget(widget) shiboken2.delete(widget) self.updateConnectionWidgets()
def test_event(): """Test that the event loop makes a Qt app.""" if QtW.QApplication.instance(): import shiboken2 shiboken2.delete(QtW.QApplication.instance()) assert not QtW.QApplication.instance() with event_loop(): app = QtW.QApplication.instance() assert app timer = QtCore.QTimer() timer.timeout.connect(lambda: app.exit()) timer.start(100)
def deleteChild(self, name): """ Remove a child collection. :param name: the name of the collection. :return: None """ assertMainThread() cc = self.getChildCollection(name) for c in cc.children(): if isinstance(c, PropertyCollectionImpl): cc.deleteChild(c.objectName()) if shiboken2.isValid(cc): # pylint: disable=no-member shiboken2.delete(cc) # pylint: disable=no-member
def delete_qapp(app): """Delete a QApplication Parameters ---------- app : qtpy.QApplication """ try: # Pyside2 from shiboken2 import delete except ImportError: # PyQt5 from sip import delete delete(app) # calling a second time is necessary on PySide2... # see: https://bugreports.qt.io/browse/PYSIDE-1470 QApplication.instance()
def testAllWrappers(self): obj = ObjectType() self.assertTrue(obj in shiboken.getAllValidWrappers()) shiboken.delete(obj) self.assertFalse(obj in shiboken.getAllValidWrappers())
def _(*args): item = table.currentItem() size = item.__data__ self.manager.del_size(size) shiboken2.delete(item)