Qt 4.8
Public Functions | Static Public Functions | Public Variables | Static Public Variables | List of all members
QCoreApplicationPrivate Class Reference

#include <qcoreapplication_p.h>

Inheritance diagram for QCoreApplicationPrivate:
QObjectPrivate QObjectData QApplicationPrivate

Public Functions

void appendApplicationPathToLibraryPaths (void)
 
virtual QString appName () const
 
void checkReceiverThread (QObject *receiver)
 
virtual void createEventDispatcher ()
 
bool notify_helper (QObject *, QEvent *)
 
void processCommandLineArguments ()
 
 QCoreApplicationPrivate (int &aargc, char **aargv, uint flags)
 
bool sendThroughApplicationEventFilters (QObject *, QEvent *)
 
bool sendThroughObjectEventFilters (QObject *, QEvent *)
 
 ~QCoreApplicationPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static bool checkInstance (const char *method)
 
static bool isTranslatorInstalled (QTranslator *translator)
 
static QString macMenuBarName ()
 
static QThreadmainThread ()
 
static QString qmljsDebugArguments ()
 
static void removePostedEvent (QEvent *)
 Removes event from the queue of posted events, and emits a warning message if appropriate. More...
 
static void removePostedTimerEvent (QObject *object, int timerId)
 
static void sendPostedEvents (QObject *receiver, int event_type, QThreadData *data)
 
static bool testAttribute (uint flag)
 
static QSettingstrolltechConf ()
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

bool aboutToQuitEmitted
 
uint application_type
 
QString applicationName
 
int & argc
 
char ** argv
 
QString cachedApplicationDirPath
 
QString cachedApplicationFilePath
 
QCoreApplication::EventFilter eventFilter
 
bool in_exec
 
QTranslatorList translators
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Static Public Variables

static int app_compile_version = 0x040000
 
static uint attribs
 
static QAbstractEventDispatchereventDispatcher = 0
 
static bool is_app_closing = false
 
static bool is_app_running = false
 
static QThreadtheMainThread = 0
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Detailed Description

Definition at line 77 of file qcoreapplication_p.h.

Constructors and Destructors

◆ QCoreApplicationPrivate()

QCoreApplicationPrivate::QCoreApplicationPrivate ( int &  aargc,
char **  aargv,
uint  flags 
)

Definition at line 428 of file qcoreapplication.cpp.

430  in_exec(false), aboutToQuitEmitted(false)
431 {
432  app_compile_version = flags & 0xffffff;
433 #if defined(QT3_SUPPORT)
434  useQt3Support = !(flags & 0x01000000);
435 #endif
436  static const char *const empty = "";
437  if (argc == 0 || argv == 0) {
438  argc = 0;
439  argv = (char **)&empty; // ouch! careful with QCoreApplication::argv()!
440  }
442 
443 #ifdef Q_OS_SYMBIAN
444  qt_init_symbian_apa_arguments(argc, argv);
445 #endif
446 
447 #ifdef Q_OS_UNIX
449 #endif
450 
451 #ifdef Q_OS_QNX
452  // make the kernel attempt to emulate an instruction with a misaligned access
453  // if the attempt fails, it faults with a SIGBUS
454  int tv = -1;
455  ThreadCtl(_NTO_TCTL_ALIGN_FAULT, &tv);
456 
457  // without Round Robin drawn intensive apps will hog the cpu
458  // and make the system appear frozen
459  int sched_policy;
460  sched_param param;
461  if (pthread_getschedparam(0, &sched_policy, &param) == 0 && sched_policy != SCHED_RR) {
462  sched_policy = SCHED_RR;
463  pthread_setschedparam(0, sched_policy, &param);
464  }
465 #endif
466 
467  // note: this call to QThread::currentThread() may end up setting theMainThread!
469  qWarning("WARNING: QApplication was not created in the main() thread.");
470 }
QCoreApplication::EventFilter eventFilter
static QThread * theMainThread
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
QObjectPrivate(int version=QObjectPrivateVersion)
Definition: qobject.cpp:133
static char * aargv[]
Q_CORE_EXPORT void qWarning(const char *,...)
static int aargc
Qt::HANDLE qt_application_thread_id
static Qt::HANDLE currentThreadId()
Returns the thread handle of the currently executing thread.

◆ ~QCoreApplicationPrivate()

QCoreApplicationPrivate::~QCoreApplicationPrivate ( )

Definition at line 472 of file qcoreapplication.cpp.

473 {
474  if (threadData) {
475 #ifndef QT_NO_THREAD
476  void *data = &threadData->tls;
477  QThreadStorageData::finish((void **)data);
478 #endif
479 
480  // need to clear the state of the mainData, just in case a new QCoreApplication comes along.
482  for (int i = 0; i < threadData->postEventList.size(); ++i) {
483  const QPostEvent &pe = threadData->postEventList.at(i);
484  if (pe.event) {
485  --pe.receiver->d_func()->postedEvents;
486  pe.event->posted = false;
487  delete pe.event;
488  }
489  }
492  threadData->quitNow = false;
493  }
494 }
static void finish(void **)
QVector< void * > tls
Definition: qthread_p.h:268
QThreadData * threadData
Definition: qobject_p.h:195
QMutex mutex
Definition: qthread_p.h:109
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static const char * data(const QByteArray &arr)
QPostEventList postEventList
Definition: qthread_p.h:266
void clear()
Removes all items from the list.
Definition: qlist.h:764
ushort posted
Definition: qcoreevent.h:319
bool quitNow
Definition: qthread_p.h:262
QEvent * event
Definition: qthread_p.h:78
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QObject * receiver
Definition: qthread_p.h:77
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

Functions

◆ appendApplicationPathToLibraryPaths()

void QCoreApplicationPrivate::appendApplicationPathToLibraryPaths ( void  )

Definition at line 550 of file qcoreapplication.cpp.

551 {
552 #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
553  QStringList *app_libpaths = coreappdata()->app_libpaths;
554  Q_ASSERT(app_libpaths);
555 # if defined(Q_OS_SYMBIAN)
557  // File existence check for application's private dir requires additional '\' or
558  // platform security will not allow it.
559  if (app_location != QLibraryInfo::location(QLibraryInfo::PluginsPath) && QFile::exists(app_location + QLatin1Char('\\')) && !app_libpaths->contains(app_location))
560 # else
562  app_location.truncate(app_location.lastIndexOf(QLatin1Char('/')));
563  app_location = QDir(app_location).canonicalPath();
564  if (QFile::exists(app_location) && !app_libpaths->contains(app_location))
565 # endif
566  app_libpaths->append(app_location);
567 #endif
568 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
static QString applicationFilePath()
Returns the file path of the application executable.
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
Definition: qfile.cpp:626
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static QString applicationDirPath()
Returns the directory that contains the application executable.
void truncate(int pos)
Truncates the string at the given position index.
Definition: qstring.cpp:4603
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
static QString location(LibraryLocation)
Returns the location specified by loc.
QString canonicalPath() const
Returns the canonical path, i.e.
Definition: qdir.cpp:642
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ appName()

QString QCoreApplicationPrivate::appName ( ) const
virtual

Reimplemented in QApplicationPrivate.

Definition at line 123 of file qcoreapplication_win.cpp.

Referenced by alert_widget().

124 {
125  return QFileInfo(qAppFileName()).baseName();
126 }
Q_CORE_EXPORT QString qAppFileName()
QString baseName() const
Returns the base name of the file without the path.
Definition: qfileinfo.cpp:773
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ checkInstance()

bool QCoreApplicationPrivate::checkInstance ( const char *  method)
static

Definition at line 222 of file qcoreapplication.cpp.

Referenced by QApplication::alert(), alert_widget(), QCoreApplication::exec(), QCoreApplication::hasPendingEvents(), QCoreApplication::installTranslator(), QApplication::keyboardInputDirection(), QApplication::keyboardInputLocale(), qAppName(), QCoreApplication::removeTranslator(), and QApplication::syncX().

223 {
224  bool b = (QCoreApplication::self != 0);
225  if (!b)
226  qWarning("QApplication::%s: Please instantiate the QApplication object first", function);
227  return b;
228 }
Q_CORE_EXPORT void qWarning(const char *,...)
static QCoreApplication * self

◆ checkReceiverThread()

void QCoreApplicationPrivate::checkReceiverThread ( QObject receiver)

Definition at line 527 of file qcoreapplication.cpp.

528 {
529  QThread *currentThread = QThread::currentThread();
530  QThread *thr = receiver->thread();
531  Q_ASSERT_X(currentThread == thr || !thr,
532  "QCoreApplication::sendEvent",
533  QString::fromLatin1("Cannot send events to objects owned by a different thread. "
534  "Current thread %1. Receiver '%2' (of type '%3') was created in thread %4")
535  .arg(QString::number((quintptr) currentThread, 16))
536  .arg(receiver->objectName())
537  .arg(QLatin1String(receiver->metaObject()->className()))
538  .arg(QString::number((quintptr) thr, 16))
539  .toLocal8Bit().data());
540  Q_UNUSED(currentThread);
541  Q_UNUSED(thr);
542 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
QString objectName
the name of this object
Definition: qobject.h:114
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
QThread * thread() const
Returns the thread in which the object lives.
Definition: qobject.cpp:1419
The QThread class provides a platform-independent way to manage threads.
Definition: qthread.h:59
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ createEventDispatcher()

void QCoreApplicationPrivate::createEventDispatcher ( )
virtual

Reimplemented in QApplicationPrivate.

Definition at line 496 of file qcoreapplication.cpp.

497 {
499 #if defined(Q_OS_SYMBIAN)
500  eventDispatcher = new QEventDispatcherSymbian(q);
501 #elif defined(Q_OS_UNIX)
502 # if defined(Q_OS_BLACKBERRY)
504 # else
505 # if !defined(QT_NO_GLIB)
506  if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported())
508  else
509 # endif
511 # endif
512 #elif defined(Q_OS_WIN)
514 #else
515 # error "QEventDispatcher not yet ported to this platform"
516 #endif
517 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
#define Q_Q(Class)
Definition: qglobal.h:2483
static bool isEmpty(const char *str)
The QCoreApplication class provides an event loop for console Qt applications.
static QAbstractEventDispatcher * eventDispatcher

◆ isTranslatorInstalled()

bool QCoreApplicationPrivate::isTranslatorInstalled ( QTranslator translator)
static

Definition at line 2028 of file qcoreapplication.cpp.

Referenced by QTranslatorPrivate::clear().

2029 {
2030  return QCoreApplication::self
2031  && QCoreApplication::self->d_func()->translators.contains(translator);
2032 }
static QCoreApplication * self

◆ macMenuBarName()

static QString QCoreApplicationPrivate::macMenuBarName ( )
static

◆ mainThread()

QThread * QCoreApplicationPrivate::mainThread ( )
static

◆ notify_helper()

bool QCoreApplicationPrivate::notify_helper ( QObject receiver,
QEvent event 
)
Warning
This function is not part of the public interface.

Helper function called by notify()

Definition at line 1077 of file qcoreapplication.cpp.

1078 {
1079  // send to all application event filters
1080  if (sendThroughApplicationEventFilters(receiver, event))
1081  return true;
1082  // send to all receiver event filters
1083  if (sendThroughObjectEventFilters(receiver, event))
1084  return true;
1085  // deliver the event
1086  return receiver->event(event);
1087 }
bool sendThroughApplicationEventFilters(QObject *, QEvent *)
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
bool sendThroughObjectEventFilters(QObject *, QEvent *)

◆ processCommandLineArguments()

void QCoreApplicationPrivate::processCommandLineArguments ( )

Definition at line 232 of file qcoreapplication.cpp.

233 {
234  int j = argc ? 1 : 0;
235  for (int i = 1; i < argc; ++i) {
236  if (argv[i] && *argv[i] != '-') {
237  argv[j++] = argv[i];
238  continue;
239  }
240  QByteArray arg = argv[i];
241  if (arg.startsWith("-qmljsdebugger=")) {
242  *qmljs_debug_arguments() = QString::fromLocal8Bit(arg.right(arg.length() - 15));
243  } else if (arg == "-qmljsdebugger" && i < argc - 1) {
244  ++i;
245  *qmljs_debug_arguments() = QString::fromLocal8Bit(argv[i]);
246  } else {
247  argv[j++] = argv[i];
248  }
249  }
250 
251  if (j < argc) {
252  argv[j] = 0;
253  argc = j;
254  }
255 }
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
bool startsWith(const QByteArray &a) const
Returns true if this byte array starts with byte array ba; otherwise returns false.
QByteArray right(int len) const
Returns a byte array that contains the rightmost len bytes of this byte array.
int length() const
Same as size().
Definition: qbytearray.h:356

◆ qmljsDebugArguments()

QString QCoreApplicationPrivate::qmljsDebugArguments ( )
static

Definition at line 570 of file qcoreapplication.cpp.

Referenced by QDeclarativeDebugServer::instance().

571 {
572  return *qmljs_debug_arguments();
573 }

◆ removePostedEvent()

void QCoreApplicationPrivate::removePostedEvent ( QEvent event)
static

Removes event from the queue of posted events, and emits a warning message if appropriate.

Warning
This function can be really slow. Avoid using it, if possible.
Note
This class or function is threadsafe.em>Reimplemented Function

Definition at line 1739 of file qcoreapplication.cpp.

Referenced by QEvent::~QEvent().

◆ removePostedTimerEvent()

void QCoreApplicationPrivate::removePostedTimerEvent ( QObject object,
int  timerId 
)
static

Definition at line 221 of file qcoreapplication_win.cpp.

Referenced by QEventDispatcherWin32Private::unregisterTimer().

222 {
223  QThreadData *data = object->d_func()->threadData;
224 
225  QMutexLocker locker(&data->postEventList.mutex);
226  if (data->postEventList.size() == 0)
227  return;
228  for (int i = 0; i < data->postEventList.size(); ++i) {
229  const QPostEvent & pe = data->postEventList.at(i);
230  if (pe.receiver == object
231  && pe.event
232  && (pe.event->type() == QEvent::Timer || pe.event->type() == QEvent::ZeroTimerEvent)
233  && static_cast<QTimerEvent *>(pe.event)->timerId() == timerId) {
234  --pe.receiver->d_func()->postedEvents;
235  pe.event->posted = false;
236  delete pe.event;
237  const_cast<QPostEvent &>(pe).event = 0;
238  return;
239  }
240  }
241 }
EventRef event
QMutex mutex
Definition: qthread_p.h:109
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static const char * data(const QByteArray &arr)
QPostEventList postEventList
Definition: qthread_p.h:266
ushort posted
Definition: qcoreevent.h:319
QEvent * event
Definition: qthread_p.h:78
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QObject * receiver
Definition: qthread_p.h:77
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ sendPostedEvents()

void QCoreApplicationPrivate::sendPostedEvents ( QObject receiver,
int  event_type,
QThreadData data 
)
static

Definition at line 1488 of file qcoreapplication.cpp.

Referenced by QEventDispatcherMac::processEvents(), QEventDispatcherUNIX::processEvents(), processPostedEvents(), qt_internal_proc(), and QCoreApplication::sendPostedEvents().

1490 {
1491  if (event_type == -1) {
1492  // we were called by an obsolete event dispatcher.
1493  event_type = 0;
1494  }
1495 
1496  if (receiver && receiver->d_func()->threadData != data) {
1497  qWarning("QCoreApplication::sendPostedEvents: Cannot send "
1498  "posted events for objects in another thread");
1499  return;
1500  }
1501 
1502  ++data->postEventList.recursion;
1503 
1504 #ifdef QT3_SUPPORT
1505  if (event_type == QEvent::ChildInserted) {
1506  if (receiver) {
1507  // optimize sendPostedEvents(w, QEvent::ChildInserted) calls away
1508  receiver->d_func()->sendPendingChildInsertedEvents();
1509  --data->postEventList.recursion;
1510  return;
1511  }
1512 
1513  // ChildInserted events are sent in response to *Request
1514  event_type = QEvent::ChildInsertedRequest;
1515  }
1516 #endif
1517 
1518  QMutexLocker locker(&data->postEventList.mutex);
1519 
1520  // by default, we assume that the event dispatcher can go to sleep after
1521  // processing all events. if any new events are posted while we send
1522  // events, canWait will be set to false.
1523  data->canWait = (data->postEventList.size() == 0);
1524 
1525  if (data->postEventList.size() == 0 || (receiver && !receiver->d_func()->postedEvents)) {
1526  --data->postEventList.recursion;
1527  return;
1528  }
1529 
1530  data->canWait = true;
1531 
1532  // okay. here is the tricky loop. be careful about optimizing
1533  // this, it looks the way it does for good reasons.
1534  int startOffset = data->postEventList.startOffset;
1535  int &i = (!event_type && !receiver) ? data->postEventList.startOffset : startOffset;
1537 
1538  while (i < data->postEventList.size()) {
1539  // avoid live-lock
1540  if (i >= data->postEventList.insertionOffset)
1541  break;
1542 
1543  const QPostEvent &pe = data->postEventList.at(i);
1544  ++i;
1545 
1546  if (!pe.event)
1547  continue;
1548  if ((receiver && receiver != pe.receiver) || (event_type && event_type != pe.event->type())) {
1549  data->canWait = false;
1550  continue;
1551  }
1552 
1553  if (pe.event->type() == QEvent::DeferredDelete) {
1554  // DeferredDelete events are only sent when we are explicitly asked to
1555  // (s.a. QEvent::DeferredDelete), and then only if the event loop that
1556  // posted the event has returned.
1557  const bool allowDeferredDelete =
1558  (quintptr(pe.event->d) > unsigned(data->loopLevel)
1559  || (!quintptr(pe.event->d) && data->loopLevel > 0)
1560  || (event_type == QEvent::DeferredDelete
1561  && quintptr(pe.event->d) == unsigned(data->loopLevel)));
1562  if (!allowDeferredDelete) {
1563  // cannot send deferred delete
1564  if (!event_type && !receiver) {
1565  // don't lose the event
1566  data->postEventList.addEvent(pe);
1567  const_cast<QPostEvent &>(pe).event = 0;
1568  }
1569  continue;
1570  }
1571  }
1572 
1573  // first, we diddle the event so that we can deliver
1574  // it, and that no one will try to touch it later.
1575  pe.event->posted = false;
1576  QEvent * e = pe.event;
1577  QObject * r = pe.receiver;
1578 
1579  --r->d_func()->postedEvents;
1580  Q_ASSERT(r->d_func()->postedEvents >= 0);
1581 
1582  // next, update the data structure so that we're ready
1583  // for the next event.
1584  const_cast<QPostEvent &>(pe).event = 0;
1585 
1586  locker.unlock();
1587  // after all that work, it's time to deliver the event.
1588 #ifdef QT_NO_EXCEPTIONS
1590 #else
1591  try {
1593  } catch (...) {
1594  delete e;
1595  locker.relock();
1596 
1597  // since we were interrupted, we need another pass to make sure we clean everything up
1598  data->canWait = false;
1599 
1600  // uglehack: copied from below
1601  --data->postEventList.recursion;
1602  if (!data->postEventList.recursion && !data->canWait && data->eventDispatcher)
1603  data->eventDispatcher->wakeUp();
1604  throw; // rethrow
1605  }
1606 #endif
1607 
1608  delete e;
1609  locker.relock();
1610 
1611  // careful when adding anything below this point - the
1612  // sendEvent() call might invalidate any invariants this
1613  // function depends on.
1614  }
1615 
1616  --data->postEventList.recursion;
1617  if (!data->postEventList.recursion && !data->canWait && data->eventDispatcher)
1618  data->eventDispatcher->wakeUp();
1619 
1620  // clear the global list, i.e. remove everything that was
1621  // delivered.
1622  if (!event_type && !receiver && data->postEventList.startOffset >= 0) {
1624  data->postEventList.erase(it, it + data->postEventList.startOffset);
1627  data->postEventList.startOffset = 0;
1628  }
1629 }
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
EventRef event
#define it(className, varName)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
void addEvent(const QPostEvent &ev)
Definition: qthread_p.h:115
bool canWait
Definition: qthread_p.h:267
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
int loopLevel
Definition: qthread_p.h:263
QMutex mutex
Definition: qthread_p.h:109
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
QPostEventList postEventList
Definition: qthread_p.h:266
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
friend class iterator
Definition: qlist.h:226
virtual void wakeUp()=0
Wakes up the event loop.
ushort posted
Definition: qcoreevent.h:319
QEventPrivate * d
Definition: qcoreevent.h:315
QEvent * event
Definition: qthread_p.h:78
iterator erase(iterator pos)
Removes the item associated with the iterator pos from the list, and returns an iterator to the next ...
Definition: qlist.h:464
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QObject * receiver
Definition: qthread_p.h:77
int insertionOffset
Definition: qthread_p.h:107
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
QAbstractEventDispatcher * eventDispatcher
Definition: qthread_p.h:264

◆ sendThroughApplicationEventFilters()

bool QCoreApplicationPrivate::sendThroughApplicationEventFilters ( QObject receiver,
QEvent event 
)

Definition at line 1035 of file qcoreapplication.cpp.

1036 {
1037  if (receiver->d_func()->threadData == this->threadData) {
1038  // application event filters are only called for objects in the GUI thread
1039  for (int i = 0; i < eventFilters.size(); ++i) {
1040  register QObject *obj = eventFilters.at(i);
1041  if (!obj)
1042  continue;
1043  if (obj->d_func()->threadData != threadData) {
1044  qWarning("QCoreApplication: Application event filter cannot be in a different thread.");
1045  continue;
1046  }
1047  if (obj->eventFilter(receiver, event))
1048  return true;
1049  }
1050  }
1051  return false;
1052 }
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QThreadData * threadData
Definition: qobject_p.h:195
QList< QPointer< QObject > > eventFilters
Definition: qobject_p.h:211
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Q_CORE_EXPORT void qWarning(const char *,...)
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ sendThroughObjectEventFilters()

bool QCoreApplicationPrivate::sendThroughObjectEventFilters ( QObject receiver,
QEvent event 
)

Definition at line 1054 of file qcoreapplication.cpp.

1055 {
1057  if (receiver != q) {
1058  for (int i = 0; i < receiver->d_func()->eventFilters.size(); ++i) {
1059  register QObject *obj = receiver->d_func()->eventFilters.at(i);
1060  if (!obj)
1061  continue;
1062  if (obj->d_func()->threadData != receiver->d_func()->threadData) {
1063  qWarning("QCoreApplication: Object event filter cannot be in a different thread.");
1064  continue;
1065  }
1066  if (obj->eventFilter(receiver, event))
1067  return true;
1068  }
1069  }
1070  return false;
1071 }
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_Q(Class)
Definition: qglobal.h:2483
Q_CORE_EXPORT void qWarning(const char *,...)
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
The QCoreApplication class provides an event loop for console Qt applications.

◆ testAttribute()

static bool QCoreApplicationPrivate::testAttribute ( uint  flag)
inlinestatic

◆ trolltechConf()

static QSettings* QCoreApplicationPrivate::trolltechConf ( )
static

Properties

◆ aboutToQuitEmitted

bool QCoreApplicationPrivate::aboutToQuitEmitted

Definition at line 125 of file qcoreapplication_p.h.

Referenced by QtWndProc().

◆ app_compile_version

int QCoreApplicationPrivate::app_compile_version = 0x040000
static

◆ application_type

uint QCoreApplicationPrivate::application_type

Definition at line 120 of file qcoreapplication_p.h.

Referenced by QApplicationPrivate::QApplicationPrivate().

◆ applicationName

QString QCoreApplicationPrivate::applicationName
mutable

Definition at line 90 of file qcoreapplication_p.h.

◆ argc

int& QCoreApplicationPrivate::argc

Definition at line 110 of file qcoreapplication_p.h.

Referenced by QApplicationPrivate::process_cmdline(), qt_init(), and qWinMain().

◆ argv

char** QCoreApplicationPrivate::argv

Definition at line 111 of file qcoreapplication_p.h.

Referenced by QApplicationPrivate::process_cmdline(), and qt_init().

◆ attribs

uint QCoreApplicationPrivate::attribs
static

Definition at line 145 of file qcoreapplication_p.h.

Referenced by qt_set_current_thread_to_main_thread().

◆ cachedApplicationDirPath

QString QCoreApplicationPrivate::cachedApplicationDirPath

Definition at line 126 of file qcoreapplication_p.h.

Referenced by QCoreApplication::applicationDirPath().

◆ cachedApplicationFilePath

QString QCoreApplicationPrivate::cachedApplicationFilePath

Definition at line 127 of file qcoreapplication_p.h.

Referenced by QCoreApplication::applicationFilePath().

◆ eventDispatcher

QAbstractEventDispatcher * QCoreApplicationPrivate::eventDispatcher = 0
static

◆ eventFilter

QCoreApplication::EventFilter QCoreApplicationPrivate::eventFilter

Definition at line 122 of file qcoreapplication_p.h.

◆ in_exec

bool QCoreApplicationPrivate::in_exec

Definition at line 124 of file qcoreapplication_p.h.

◆ is_app_closing

bool QCoreApplicationPrivate::is_app_closing = false
static

◆ is_app_running

bool QCoreApplicationPrivate::is_app_running = false
static

◆ theMainThread

QThread * QCoreApplicationPrivate::theMainThread = 0
static

◆ translators

QTranslatorList QCoreApplicationPrivate::translators

The documentation for this class was generated from the following files: