{"body":"#############################################################################\n##\n## Copyright (C) 2016 The Qt Company Ltd.\n## Contact: https://www.qt.io/licensing/\n##\n## This file is part of the test suite of Qt for Python.\n##\n## $QT_BEGIN_LICENSE:GPL-EXCEPT$\n## Commercial License Usage\n## Licensees holding valid commercial Qt licenses may use this file in\n## accordance with the commercial license agreement provided with the\n## Software or, alternatively, in accordance with the terms contained in\n## a written agreement between you and The Qt Company. For licensing terms\n## and conditions see https://www.qt.io/terms-conditions. For further\n## information use the contact form at https://www.qt.io/contact-us.\n##\n## GNU General Public License Usage\n## Alternatively, this file may be used under the terms of the GNU\n## General Public License version 3 as published by the Free Software\n## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT\n## included in the packaging of this file. Please review the following\n## information to ensure the GNU General Public License requirements will\n## be met: https://www.gnu.org/licenses/gpl-3.0.html.\n##\n## $QT_END_LICENSE$\n##\n#############################################################################\n\nimport os\nimport sys\nimport unittest\n\nfrom pathlib import Path\nsys.path.append(os.fspath(Path(__file__).resolve().parents[1]))\nfrom init_paths import init_test_paths\ninit_test_paths(False)\n\nfrom PySide6.QtCore import QObject, QCoreApplication, QEvent, QThread\n\n\nclass MyEvent(QEvent):\n    def __init__(self, i):\n        print(\"TYPE:\", type(QEvent.User))\n        super().__init__(QEvent.Type(QEvent.User + 100))\n        self.i = i\n\n\nclass MyThread (QThread):\n    def __init__(self, owner):\n        super().__init__()\n        self.owner = owner\n\n    def run(self):\n        for i in range(3):\n            e = MyEvent(i)\n            QCoreApplication.postEvent(self.owner, e)\n\n\nclass MyBaseObject(QObject):\n    def __init__(self):\n        super().__init__()\n        self.events = []\n        self.t = MyThread(self)\n        self.t.start()\n\n    def customEvent(self, event):\n        self.events.append(event)\n        if len(self.events) == 3:\n            self.t.wait()\n            self.app.quit()\n\n\nclass CheckForEventsTypes(unittest.TestCase):\n    def testTypes(self):\n        o = MyBaseObject()\n        o.app = QCoreApplication(sys.argv)\n        o.app.exec()\n        for e in o.events:\n            self.assertTrue(isinstance(e, MyEvent))\n        o.app = None\n\n\nif __name__ == '__main__':\n    unittest.main()\n","name":"bug_462.py","extension":"py","url":"https://www.irccloud.com/pastebin/1yHQrD68/bug_462.py","modified":1645787934,"id":"1yHQrD68","size":2574,"lines":84,"own_paste":false,"theme":"","date":1645787934}