summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/kernel/qtimer.h8
-rw-r--r--src/network/kernel/qhostinfo.h4
-rw-r--r--src/widgets/widgets/qmenu.h8
-rw-r--r--src/widgets/widgets/qtoolbar.h4
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp11
5 files changed, 21 insertions, 14 deletions
diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h
index 6e61ca10cb..7db5fc759b 100644
--- a/src/corelib/kernel/qtimer.h
+++ b/src/corelib/kernel/qtimer.h
@@ -122,14 +122,14 @@ public:
!std::is_same<const char*, Func1>::value, void>::type
singleShot(Duration interval, Func1 slot)
{
- singleShot(interval, defaultTypeFor(interval), nullptr, slot);
+ singleShot(interval, defaultTypeFor(interval), nullptr, std::move(slot));
}
template <typename Duration, typename Func1>
static inline typename std::enable_if<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
!std::is_same<const char*, Func1>::value, void>::type
singleShot(Duration interval, Qt::TimerType timerType, Func1 slot)
{
- singleShot(interval, timerType, nullptr, slot);
+ singleShot(interval, timerType, nullptr, std::move(slot));
}
// singleShot to a functor or function pointer (with context)
template <typename Duration, typename Func1>
@@ -137,7 +137,7 @@ public:
!std::is_same<const char*, Func1>::value, void>::type
singleShot(Duration interval, QObject *context, Func1 slot)
{
- singleShot(interval, defaultTypeFor(interval), context, slot);
+ singleShot(interval, defaultTypeFor(interval), context, std::move(slot));
}
template <typename Duration, typename Func1>
static inline typename std::enable_if<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
@@ -150,7 +150,7 @@ public:
singleShotImpl(interval, timerType, context,
new QtPrivate::QFunctorSlotObject<Func1, 0,
- typename QtPrivate::List_Left<void, 0>::Value, void>(slot));
+ typename QtPrivate::List_Left<void, 0>::Value, void>(std::move(slot)));
}
#endif
diff --git a/src/network/kernel/qhostinfo.h b/src/network/kernel/qhostinfo.h
index 4484d718bd..00c70ae9b9 100644
--- a/src/network/kernel/qhostinfo.h
+++ b/src/network/kernel/qhostinfo.h
@@ -125,7 +125,7 @@ public:
!std::is_same<const char *, Func>::value, int>::type
lookupHost(const QString &name, Func slot)
{
- return lookupHost(name, nullptr, slot);
+ return lookupHost(name, nullptr, std::move(slot));
}
// lookupHost to a functor or function pointer (with context)
@@ -141,7 +141,7 @@ public:
auto slotObj = new QtPrivate::QFunctorSlotObject<Func1, 1,
typename QtPrivate::List<QHostInfo>,
- void>(slot);
+ void>(std::move(slot));
return lookupHostImpl(name, context, slotObj);
}
#endif // Q_QDOC
diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h
index e9a5db1112..dbfd12124c 100644
--- a/src/widgets/widgets/qmenu.h
+++ b/src/widgets/widgets/qmenu.h
@@ -108,7 +108,7 @@ public:
#else
result->setShortcut(shortcut);
#endif
- connect(result, &QAction::triggered, object, slot);
+ connect(result, &QAction::triggered, object, std::move(slot));
return result;
}
// addAction(QString): Connect to a functor or function pointer (without context)
@@ -121,7 +121,7 @@ public:
#else
result->setShortcut(shortcut);
#endif
- connect(result, &QAction::triggered, slot);
+ connect(result, &QAction::triggered, std::move(slot));
return result;
}
// addAction(QIcon, QString): Connect to a QObject slot / functor or function pointer (with context)
@@ -136,7 +136,7 @@ public:
#else
result->setShortcut(shortcut);
#endif
- connect(result, &QAction::triggered, object, slot);
+ connect(result, &QAction::triggered, object, std::move(slot));
return result;
}
// addAction(QIcon, QString): Connect to a functor or function pointer (without context)
@@ -149,7 +149,7 @@ public:
#else
result->setShortcut(shortcut);
#endif
- connect(result, &QAction::triggered, slot);
+ connect(result, &QAction::triggered, std::move(slot));
return result;
}
#endif // !Q_QDOC
diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h
index e0f2d9b073..9ffb472c76 100644
--- a/src/widgets/widgets/qtoolbar.h
+++ b/src/widgets/widgets/qtoolbar.h
@@ -121,7 +121,7 @@ public:
addAction(const QString &text, const Obj *object, Func1 slot)
{
QAction *result = addAction(text);
- connect(result, &QAction::triggered, object, slot);
+ connect(result, &QAction::triggered, object, std::move(slot));
return result;
}
// addAction(QString): Connect to a functor or function pointer (without context)
@@ -139,7 +139,7 @@ public:
addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot)
{
QAction *result = addAction(actionIcon, text);
- connect(result, &QAction::triggered, object, slot);
+ connect(result, &QAction::triggered, object, std::move(slot));
return result;
}
// addAction(QIcon, QString): Connect to a functor or function pointer (without context)
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index 3c2989831e..bcae39af3d 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -834,7 +834,6 @@ void tst_QTimer::singleShotToFunctors()
QTest::qWait(800);
QCOMPARE(count, 2);
-#if defined(Q_COMPILER_LAMBDA)
QTimer::singleShot(0, [&count] { ++count; });
QCoreApplication::processEvents();
QCOMPARE(count, 3);
@@ -853,7 +852,15 @@ void tst_QTimer::singleShotToFunctors()
thread.quit();
thread.wait();
-#endif
+
+ struct MoveOnly : CountedStruct {
+ Q_DISABLE_COPY(MoveOnly);
+ MoveOnly(MoveOnly &&o) : CountedStruct(std::move(o)) {};
+ MoveOnly(int *c) : CountedStruct(c) {}
+ };
+ QTimer::singleShot(0, MoveOnly(&count));
+ QCoreApplication::processEvents();
+ QCOMPARE(count, 5);
_e.reset();
_t = Q_NULLPTR;