From 44e25bdf008742570619877e82ba603b3520b08f Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Mon, 27 Jan 2014 17:23:13 +0100 Subject: Get rid of tr1/functional This header requires rtti in libstdc++ on Mac, which we can't recommend since Qt itself is usually built without rtti. Replace its uses with simpler hand-made template functors. Change-Id: Ic020dcceaf262f77d92b31a8318a513fa200428d Reviewed-by: Simon Hausmann --- .../qwebengineframe/tst_qwebengineframe.cpp | 4 +-- tests/auto/widgets/util.h | 30 ++++++++++++---------- 2 files changed, 19 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp b/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp index 99ad21152..b38a7fdfe 100644 --- a/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp +++ b/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp @@ -406,8 +406,8 @@ void tst_QWebEngineFrame::asyncAndDelete() QWebEnginePage *page = new QWebEnginePage; CallbackSpy plainTextSpy; CallbackSpy htmlSpy; - page->toPlainText(ref(plainTextSpy)); - page->toHtml(ref(htmlSpy)); + page->toPlainText(plainTextSpy.ref()); + page->toHtml(htmlSpy.ref()); delete page; // Pending callbacks should be called with an empty value in the page's destructor. diff --git a/tests/auto/widgets/util.h b/tests/auto/widgets/util.h index a9a3d487c..5adc7e1b7 100644 --- a/tests/auto/widgets/util.h +++ b/tests/auto/widgets/util.h @@ -27,14 +27,6 @@ #include #include -#if __cplusplus >= 201103L -#include -using std::ref; -#else -#include -using std::tr1::ref; -#endif - #if !defined(TESTS_SOURCE_DIR) #define TESTS_SOURCE_DIR "" #endif @@ -87,12 +79,17 @@ public: } }; +template +struct RefWrapper { + R &ref; + void operator()(const T& result) { + ref(result); + } +}; + template class CallbackSpy { public: - // Tells tr1::ref the result of void operator()(const T &result) when decltype isn't available. - typedef void result_type; - CallbackSpy() : called(false) { timeoutTimer.setSingleShot(true); QObject::connect(&timeoutTimer, SIGNAL(timeout()), &eventLoop, SLOT(quit())); @@ -116,6 +113,13 @@ public: eventLoop.quit(); } + // Cheap rip-off of boost/std::ref + RefWrapper > ref() + { + RefWrapper > wrapper = {*this}; + return wrapper; + } + private: Q_DISABLE_COPY(CallbackSpy) bool called; @@ -127,14 +131,14 @@ private: static inline QString toPlainText(QWebEnginePage *page) { CallbackSpy spy; - page->toPlainText(ref(spy)); + page->toPlainText(spy.ref()); return spy.waitForResult(); } static inline QString toHtml(QWebEnginePage *page) { CallbackSpy spy; - page->toHtml(ref(spy)); + page->toHtml(spy.ref()); return spy.waitForResult(); } -- cgit v1.2.1