summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcoreapplication.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qcoreapplication.cpp')
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp68
1 files changed, 11 insertions, 57 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index cf3ae1b7c5..2d49b271ce 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -1011,35 +1011,6 @@ void QCoreApplication::exit(int returnCode)
*/
/*!
- Adds the event \a event, with the object \a receiver as the
- receiver of the event, to an event queue and returns immediately.
-
- The event must be allocated on the heap since the post event queue
- will take ownership of the event and delete it once it has been
- posted. It is \e {not safe} to access the event after
- it has been posted.
-
- When control returns to the main event loop, all events that are
- stored in the queue will be sent using the notify() function.
-
- Events are processed in the order posted. For more control over
- the processing order, use the postEvent() overload below, which
- takes a priority argument. This function posts all event with a
- Qt::NormalEventPriority.
-
- \threadsafe
-
- \sa sendEvent(), notify(), sendPostedEvents()
-*/
-
-void QCoreApplication::postEvent(QObject *receiver, QEvent *event)
-{
- postEvent(receiver, event, Qt::NormalEventPriority);
-}
-
-
-/*!
- \overload postEvent()
\since 4.3
Adds the event \a event, with the object \a receiver as the
@@ -1167,13 +1138,6 @@ bool QCoreApplication::compressEvent(QEvent *event, QObject *receiver, QPostEven
}
/*!
- \fn void QCoreApplication::sendPostedEvents()
- \overload sendPostedEvents()
-
- Dispatches all posted events, i.e. empties the event queue.
-*/
-
-/*!
Immediately dispatches all events which have been previously queued
with QCoreApplication::postEvent() and which are for the object \a receiver
and have the event type \a event_type.
@@ -1188,7 +1152,6 @@ bool QCoreApplication::compressEvent(QEvent *event, QObject *receiver, QPostEven
\sa flush(), postEvent()
*/
-
void QCoreApplication::sendPostedEvents(QObject *receiver, int event_type)
{
QThreadData *data = QThreadData::current();
@@ -1343,23 +1306,6 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type
}
/*!
- Removes all events posted using postEvent() for \a receiver.
-
- The events are \e not dispatched, instead they are removed from the
- queue. You should never need to call this function. If you do call it,
- be aware that killing events may cause \a receiver to break one or
- more invariants.
-
- \threadsafe
-*/
-
-void QCoreApplication::removePostedEvents(QObject *receiver)
-{
- removePostedEvents(receiver, 0);
-}
-
-/*!
- \overload removePostedEvents()
\since 4.3
Removes all events of the given \a eventType that were posted
@@ -1372,7 +1318,9 @@ void QCoreApplication::removePostedEvents(QObject *receiver)
If \a receiver is null, the events of \a eventType are removed for
all objects. If \a eventType is 0, all the events are removed for
- \a receiver.
+ \a receiver. You should never call this function with \a eventType
+ of 0. If you do call it in this way, be aware that killing events
+ may cause \a receiver to break one or more invariants.
\threadsafe
*/
@@ -1506,8 +1454,14 @@ void QCoreApplicationPrivate::ref()
void QCoreApplicationPrivate::deref()
{
- if (!quitLockRef.deref() && in_exec && quitLockRefEnabled)
- QCoreApplication::postEvent(qApp, new QEvent(QEvent::Quit));
+ if (!quitLockRef.deref())
+ maybeQuit();
+}
+
+void QCoreApplicationPrivate::maybeQuit()
+{
+ if (quitLockRef.load() == 0 && in_exec && quitLockRefEnabled && shouldQuit())
+ QCoreApplication::postEvent(QCoreApplication::instance(), new QEvent(QEvent::Quit));
}
/*!