QGestureRecognizer.registerRecognizer() crashes using PySide2
-
PanGestureRecognizer doesn't have an
__init__
to callQGestureRecognizer.__init__
. I vaguely recall reports of misbehavior using PyQt if a Qt object's constructor isn't invoked. This may have been limited to QObjects. It might not apply to PySide. Either way, it's an inexpensive experiment to run. QGestureRecognizer's C++ constructor is empty, but there may be some bookkeeping on the Python side.@jeremy_k you mean, I should try just calling QGestureRecognizer's
__init__
inPanGestureRecognizer.__init__
? I would've guessed that's ambiguous, or does instanciation lead to a direct call of the C++ parent constructor instead of the parent's__init__
in Python? However, I just tried, still no luck :/ -
@jeremy_k you mean, I should try just calling QGestureRecognizer's
__init__
inPanGestureRecognizer.__init__
? I would've guessed that's ambiguous, or does instanciation lead to a direct call of the C++ parent constructor instead of the parent's__init__
in Python? However, I just tried, still no luck :/class PanGestureRecognizer(QGestureRecognizer): def __init__(self): super().__init__()
This doesn't seem to be necessary with pure python classes. The wording of object.__init__ led me to believe that it was, but a test suggests that the base class __init__ is called if no derived __init__ is defined.
-
class PanGestureRecognizer(QGestureRecognizer): def __init__(self): super().__init__()
This doesn't seem to be necessary with pure python classes. The wording of object.__init__ led me to believe that it was, but a test suggests that the base class __init__ is called if no derived __init__ is defined.
@jeremy_k
Well, in Python just like in, say, C++, if you do not define your own__init__()
(constructor in C++) the language will always cause the base class's__init__()
/constructor. If you do define your own, you must then explicitly call the base class__init__()
/constructor, in either language.in Python.[EDIT As @jeremy_k pointed out below, I was wrong to say this applies in all C++ cases. Let's leave it as: in Python, if you define any derived
__init__()
you must (should) explicitly call the base__init__()
from there; but if you do not define a derived__init__()
the base one will still be called.]I vaguely recall reports of misbehavior using PyQt if a Qt object's constructor isn't invoked
I don't know if somehow PySide2/PyQt requires you to explicitly define your own
__init__()
and call the base, unless you have some reference for that? -
@jeremy_k
Well, in Python just like in, say, C++, if you do not define your own__init__()
(constructor in C++) the language will always cause the base class's__init__()
/constructor. If you do define your own, you must then explicitly call the base class__init__()
/constructor, in either language.in Python.[EDIT As @jeremy_k pointed out below, I was wrong to say this applies in all C++ cases. Let's leave it as: in Python, if you define any derived
__init__()
you must (should) explicitly call the base__init__()
from there; but if you do not define a derived__init__()
the base one will still be called.]I vaguely recall reports of misbehavior using PyQt if a Qt object's constructor isn't invoked
I don't know if somehow PySide2/PyQt requires you to explicitly define your own
__init__()
and call the base, unless you have some reference for that?@JonB said in QGestureRecognizer.registerRecognizer() crashes using PySide2:
@jeremy_k
Well, in Python just like in, say, C++, if you do not define your own__init__()
(constructor in C++) the language will always cause the base class's__init__()
/constructor. If you do define your own, you must then explicitly call the base class__init__()
/constructor, in either language.That's inaccurate for C++ base class default constructors. The compiler will insert a call to the base constructor if the programmer does not. Explicit invocation is only required if there are arguments to pass.
-
@JonB said in QGestureRecognizer.registerRecognizer() crashes using PySide2:
@jeremy_k
Well, in Python just like in, say, C++, if you do not define your own__init__()
(constructor in C++) the language will always cause the base class's__init__()
/constructor. If you do define your own, you must then explicitly call the base class__init__()
/constructor, in either language.That's inaccurate for C++ base class default constructors. The compiler will insert a call to the base constructor if the programmer does not. Explicit invocation is only required if there are arguments to pass.
@jeremy_k
You are quite correct, and thank you for pointing this out. Partly I was unconsciously thinking of constructors with parameters, and partly I make slips as I swap between C#/C++/Python/JavaScript! I will correct my previous post, so as not to mislead. -
You may have found a bug in the PySide2 implementation. Did you check if you have the same behaviour with PySide6 ?
-
You may have found a bug in the PySide2 implementation. Did you check if you have the same behaviour with PySide6 ?
-
Then you should go to the bug report system and see if there's already something there. If not, please consider opening a new issue providing your minimal runnable script that shows that behaviour.
-
It's an issue on Python and it has likely not been used that much with that language. You can add a comment on the issue to remind the current assigned person that this is still not solved.