Exemple #1
0
    def testSetPixmap(self):

        p1 = QPixmap(5, 5)
        p2 = QPixmap(10, 10)

        self.label.setPixmap(p1)
        self.assertIsNotNone(self.label.pixmap())

        # PYSIDE-150:
        #   When a new QPixmap is assigned to a QLabel,
        #   the previous one needs to be cleared.
        #   This means we should not keep a copy of the QPixmap
        #   on Python-side.

        # Getting pointer to the QPixmap
        ret_p = self.label.pixmap()
        self.assertIsNot(p1, ret_p)
        # Save the address of the pointer
        ret_p_addr = shiboken.getCppPointer(ret_p)
        # Remove the QPixmap
        del ret_p
        # Set new QPixmap
        self.label.setPixmap(p2)

        # There should be no pointers remaining with the same
        # address that our QPixmap p1 because it was deleted
        # using `del ret_p`
        self.assertTrue(
            all(
                shiboken.getCppPointer(o) != ret_p_addr
                for o in shiboken.getAllValidWrappers()))
Exemple #2
0
 def testAllWrappers(self):
     obj = ObjectType()
     self.assertTrue(obj in shiboken.getAllValidWrappers())
     shiboken.delete(obj)
     self.assertFalse(obj in shiboken.getAllValidWrappers())