1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include <QtCore/QObject>
class MyObject_hasEventFilter : public QObject
{
protected:
bool eventFilter(QObject *, QEvent *) override;
};
class MyObject_doesntHaveEventFilter : public QObject
{
};
class Obj : public QObject
{
public:
Obj(MyObject_hasEventFilter* other)
{
other->installEventFilter(this); // OK
other->installEventFilter(other); // OK
installEventFilter(other); // OK
installEventFilter(this); // Warning
this->installEventFilter(other); // OK
}
void test2(MyObject_doesntHaveEventFilter *other)
{
other->installEventFilter(this); // OK
other->installEventFilter(other); // OK
installEventFilter(this); // Warning
this->installEventFilter(other); // Warning
installEventFilter(other); // Warning
}
};
class DerivedDerived : public Obj {};
class DerivedDerived2 : public MyObject_hasEventFilter {};
class TestBiggerHierarchy : public QObject
{
void test(DerivedDerived *d1, DerivedDerived2 *d2)
{
installEventFilter(d1); // Warning
installEventFilter(d2); // OK
}
};
class NoThisInvolved : public QObject
{
void installEventFilterLocal()
{
QObject o;
o.installEventFilter(this); // OK, no crash
}
};
|