Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'qt_tstfrm/test_main_loop.cpp')
-rw-r--r--qt_tstfrm/test_main_loop.cpp45
1 files changed, 26 insertions, 19 deletions
diff --git a/qt_tstfrm/test_main_loop.cpp b/qt_tstfrm/test_main_loop.cpp
index 1e71a14041..d5db995773 100644
--- a/qt_tstfrm/test_main_loop.cpp
+++ b/qt_tstfrm/test_main_loop.cpp
@@ -8,12 +8,30 @@
#include "../std/cstring.hpp"
-TestMainLoop::TestMainLoop(TestMainLoop::TRednerFn const & fn)
- : m_renderFn(fn)
+namespace
{
-}
-void TestMainLoop::exec(char const * testName, bool autoExit)
+class MyWidget : public QWidget
+{
+public:
+ MyWidget(TRednerFn const & fn)
+ : m_fn(fn)
+ {
+ }
+
+protected:
+ void paintEvent(QPaintEvent * e)
+ {
+ m_fn(this);
+ }
+
+private:
+ TRednerFn m_fn;
+};
+
+} // namespace
+
+void RunTestLoop(char const * testName, TRednerFn const & fn, bool autoExit)
{
char * buf = (char *)malloc(strlen(testName) + 1);
MY_SCOPE_GUARD(argvFreeFun, [&buf](){ free(buf); });
@@ -24,21 +42,10 @@ void TestMainLoop::exec(char const * testName, bool autoExit)
if (autoExit)
QTimer::singleShot(3000, &app, SLOT(quit()));
- QWidget w;
- w.setWindowTitle(testName);
- w.show();
- w.installEventFilter(this);
+ MyWidget * widget = new MyWidget(fn);
+ widget->setWindowTitle(testName);
+ widget->show();
app.exec();
-}
-
-bool TestMainLoop::eventFilter(QObject * obj, QEvent * event)
-{
- if (event->type() == QEvent::Paint)
- {
- m_renderFn(qobject_cast<QWidget *>(obj));
- return true;
- }
-
- return false;
+ delete widget;
}