Skip to content

Commit

Permalink
QTimer: fix compilation with C++20
Browse files Browse the repository at this point in the history
Implicit capture of *this by [=] is deprecated in C++20, and the
replacement [=,this] is not available in C++17. We also can't use [&],
because of QueuedConnection, so need to bite the bullet and list all
captured variables separately.

Amends 87535e4.

Change-Id: I5b3a713bf9220746d10d594d1a248028157ad170
Reviewed-by: Mårten Nordheim <[email protected]>
Reviewed-by: Fabian Kosmale <[email protected]>
Reviewed-by: Giuseppe D'Angelo <[email protected]>
  • Loading branch information
marcmutz committed May 2, 2023
1 parent 51bcad8 commit 106c2fd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/corelib/kernel/qtimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void QSingleShotTimer::startTimerForReceiver(int msec, Qt::TimerType timerType,
moveToThread(receiver->thread());

QDeadlineTimer deadline(std::chrono::milliseconds{msec}, timerType);
QMetaObject::invokeMethod(this, [=]{
QMetaObject::invokeMethod(this, [this, deadline, timerType]{
if (deadline.hasExpired())
emit timeout();
else
Expand Down

0 comments on commit 106c2fd

Please sign in to comment.