tests: Remove some QPointer usage
Which in turn also removes some asQWidget() usage
This commit is contained in:
@@ -127,6 +127,25 @@ bool Platform_qt::tests_waitForEvent(std::shared_ptr<Window> window, QEvent::Typ
|
||||
return tests_waitForEvent(windowqt->qtWindow(), type, timeout);
|
||||
}
|
||||
|
||||
bool Platform_qt::tests_waitForDeleted(View *view, int timeout) const
|
||||
{
|
||||
QObject *o = view ? view->asQObject() : nullptr;
|
||||
if (!o)
|
||||
return true;
|
||||
|
||||
QPointer<QObject> ptr = o;
|
||||
QElapsedTimer time;
|
||||
time.start();
|
||||
|
||||
while (ptr && time.elapsed() < timeout) {
|
||||
qApp->processEvents();
|
||||
QTest::qWait(50);
|
||||
}
|
||||
|
||||
const bool wasDeleted = !ptr;
|
||||
return wasDeleted;
|
||||
}
|
||||
|
||||
void Platform_qt::tests_sendEvent(View *view, QEvent *ev) const
|
||||
{
|
||||
qApp->sendEvent(view->asQObject(), ev);
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
bool tests_waitForEvent(std::shared_ptr<Window>, QEvent::Type type, int timeout = 5000) const override;
|
||||
bool tests_waitForResize(View *, int timeout = 2000) const override;
|
||||
bool tests_waitForResize(Controller *, int timeout = 2000) const override;
|
||||
bool tests_waitForDeleted(View *, int timeout = 2000) const override;
|
||||
void tests_sendEvent(std::shared_ptr<Window>, QEvent *) const override;
|
||||
void tests_sendEvent(View *, QEvent *) const override;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user