QEventLoop: port processEvents() to QDeadlineTimer
[ChangeLog][QtCore][QEventLoop] Added a processEvents() overload that takes a QDeadlineTimer. Task-number: QTBUG-110059 Change-Id: I239dbeec33cb4f10d1ecd44a8455e7bd808f378b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
fa296ee1dc
commit
4f618bde08
@ -6,7 +6,7 @@
|
||||
#include "qabstracteventdispatcher.h"
|
||||
#include "qcoreapplication.h"
|
||||
#include "qcoreapplication_p.h"
|
||||
#include "qelapsedtimer.h"
|
||||
#include "qdeadlinetimer.h"
|
||||
|
||||
#include "qobject_p.h"
|
||||
#include "qeventloop_p.h"
|
||||
@ -186,9 +186,27 @@ int QEventLoop::exec(ProcessEventsFlags flags)
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
|
||||
Process pending events that match \a flags for a maximum of \a
|
||||
maxTime milliseconds, or until there are no more events to
|
||||
process, whichever is shorter.
|
||||
|
||||
Equivalent to calling:
|
||||
\code
|
||||
processEvents(flags, QDeadlineTimer(maxTime));
|
||||
\endcode
|
||||
*/
|
||||
void QEventLoop::processEvents(ProcessEventsFlags flags, int maxTime)
|
||||
{
|
||||
processEvents(flags, QDeadlineTimer(maxTime));
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 6.7
|
||||
|
||||
Process pending events that match \a flags until \a deadline has expired,
|
||||
or until there are no more events to process, whichever happens first.
|
||||
This function is especially useful if you have a long running
|
||||
operation and want to show its progress without allowing user
|
||||
input, i.e. by using the \l ExcludeUserInputEvents flag.
|
||||
@ -201,16 +219,14 @@ int QEventLoop::exec(ProcessEventsFlags flags)
|
||||
and will be ignored.
|
||||
\endlist
|
||||
*/
|
||||
void QEventLoop::processEvents(ProcessEventsFlags flags, int maxTime)
|
||||
void QEventLoop::processEvents(ProcessEventsFlags flags, QDeadlineTimer deadline)
|
||||
{
|
||||
Q_D(QEventLoop);
|
||||
if (!d->threadData.loadRelaxed()->hasEventDispatcher())
|
||||
return;
|
||||
|
||||
QElapsedTimer start;
|
||||
start.start();
|
||||
while (processEvents(flags & ~WaitForMoreEvents)) {
|
||||
if (start.elapsed() > maxTime)
|
||||
if (deadline.hasExpired())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#define QEVENTLOOP_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qdeadlinetimer.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -34,6 +35,7 @@ public:
|
||||
|
||||
bool processEvents(ProcessEventsFlags flags = AllEvents);
|
||||
void processEvents(ProcessEventsFlags flags, int maximumTime);
|
||||
void processEvents(ProcessEventsFlags flags, QDeadlineTimer deadline);
|
||||
|
||||
int exec(ProcessEventsFlags flags = AllEvents);
|
||||
bool isRunning() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user