File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818import pytest
1919
2020import qasync
21-
2221from qasync import QtCore
23- import traceback , logging
24-
25- _orig_setParent = QtCore .QObject .setParent
26-
27-
28- def _dbg_setParent (self , parent ):
29- if parent is not None :
30- try :
31- same = parent .thread () is self .thread ()
32- except Exception :
33- same = False
34- if not same :
35- logging .error (
36- "QObject.setParent across threads: obj=%r obj.thread=%r parent=%r parent.thread=%r" ,
37- self ,
38- self .thread (),
39- parent ,
40- getattr (parent , "thread" , lambda : None )(),
41- )
42- traceback .print_stack () # prints Python stack where setParent was called
43- # Optionally raise so test fails and you can inspect the stack in the debugger:
44- # raise RuntimeError("setParent called from wrong thread")
45- return _orig_setParent (self , parent )
46-
47-
48- QtCore .QObject .setParent = _dbg_setParent
4922
5023
5124@pytest .fixture
You can’t perform that action at this time.
0 commit comments