src/corelib/kernel/qcoreapplication.cpp File Reference

#include "qcoreapplication.h"
#include "qcoreapplication_p.h"
#include "qabstracteventdispatcher.h"
#include "qcoreevent.h"
#include "qeventloop.h"
#include <qdatastream.h>
#include <qdatetime.h>
#include <qdebug.h>
#include <qdir.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qhash.h>
#include <private/qprocess_p.h>
#include <qtextcodec.h>
#include <qthread.h>
#include <qthreadstorage.h>
#include <private/qthread_p.h>
#include <qlibraryinfo.h>
#include "qeventdispatcher_glib_p.h"
#include "qeventdispatcher_unix_p.h"
#include <stdlib.h>
#include <locale.h>

Include dependency graph for qcoreapplication.cpp:

Go to the source code of this file.

Classes

struct  QCoreApplicationData

Typedefs

typedef QList< QtCleanUpFunctionQVFuncList

Functions

void qt_register_signal_spy_callbacks (const QSignalSpyCallbackSet &callback_set)
void Q_CORE_EXPORT qt_startup_hook ()
void qAddPostRoutine (QtCleanUpFunction p)
void qRemovePostRoutine (QtCleanUpFunction p)
void Q_CORE_EXPORT qt_call_post_routines ()
Q_CORE_EXPORT uint qGlobalPostedEventsCount ()
void qt_set_current_thread_to_main_thread ()
QString qAppName ()
void set_winapp_name ()
 Q_GLOBAL_STATIC_WITH_ARGS (QMutex, libraryPathMutex,(QMutex::Recursive)) QStringList QCoreApplication

Variables

QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set = { 0, 0, 0, 0 }
Qt::HANDLE qt_application_thread_id = 0


Typedef Documentation

typedef QList<QtCleanUpFunction> QVFuncList

Definition at line 97 of file qcoreapplication.cpp.


Function Documentation

Q_GLOBAL_STATIC_WITH_ARGS ( QMutex  ,
libraryPathMutex  ,
(QMutex::Recursive)   
)

Returns a list of paths that the application will search when dynamically loading libraries.

This list will include the installation directory for plugins if it exists (the default installation directory for plugins is INSTALL/plugins, where INSTALL is the directory where Qt was installed). The directory of the application executable (NOT the working directory) is always added, as well as the colon separated entries of the QT_PLUGIN_PATH environment variable.

If you want to iterate over the list, you can use the foreach pseudo-keyword:

        foreach (QString path, app.libraryPaths())
            do_something(path);

See also:
setLibraryPaths(), addLibraryPath(), removeLibraryPath(), QLibrary, {How to Create Qt Plugins}

Definition at line 1700 of file qcoreapplication.cpp.

References QList< T >::append(), QList< QString >::const_iterator, QList< T >::constBegin(), QList< T >::constEnd(), QFile::exists(), QString::fromLatin1(), QByteArray::isEmpty(), QLibraryInfo::location(), QLibraryInfo::PluginsPath, qgetenv(), QString::SkipEmptyParts, and QString::split().

01714                   :
01715 
01716     \code
01717         foreach (QString path, app.libraryPaths())
01718             do_something(path);
01719     \endcode
01720 
01721     \sa setLibraryPaths(), addLibraryPath(), removeLibraryPath(), QLibrary,
01722         {How to Create Qt Plugins}
01723 */
01724 QStringList QCoreApplication::libraryPaths()
01725 {
01726     QMutexLocker locker(libraryPathMutex());
01727     if (!self)
01728         return QStringList();
01729     if (!coreappdata()->app_libpaths) {
01730         QStringList *app_libpaths = coreappdata()->app_libpaths = new QStringList;
01731         QString installPathPlugins =  QLibraryInfo::location(QLibraryInfo::PluginsPath);
01732         if (QFile::exists(installPathPlugins)) {
01733             // Make sure we convert from backslashes to slashes.
01734             installPathPlugins = QDir(installPathPlugins).canonicalPath();
01735             app_libpaths->append(installPathPlugins);
01736         }
01737 
01738         // If QCoreApplication is not yet instantiated,
01739         // make sure we add the application path when we construct the QCoreApplication
01740         if (self) self->d_func()->appendApplicationPathToLibraryPaths();
01741 
01742         const QByteArray libPathEnv = qgetenv("QT_PLUGIN_PATH");
01743         if (!libPathEnv.isEmpty()) {
01744 #ifdef Q_OS_WIN
01745             QLatin1Char pathSep(';');
01746 #else
01747             QLatin1Char pathSep(':');
01748 #endif
01749             QStringList paths = QString::fromLatin1(libPathEnv).split(pathSep, QString::SkipEmptyParts);
01750             for (QStringList::const_iterator it = paths.constBegin(); it != paths.constEnd(); ++it) {
01751                 app_libpaths->append(QDir(*it).canonicalPath());
01752             }
01753         }
01754     }
01755     return *(coreappdata()->app_libpaths);
01756 }

Here is the call graph for this function:

void qAddPostRoutine ( QtCleanUpFunction  p  )  [related]

Definition at line 100 of file qcoreapplication.cpp.

References QList< T >::prepend().

Referenced by QSqlDatabasePrivate::driverDict(), QTestAccessibility::initialize(), QAccessible::installFactory(), Q3DnsManager::manager(), Q3ProcessPrivate::newProc(), QGLCMapCleanupHandler::QGLCMapCleanupHandler(), QLibrarySettings::QLibrarySettings(), QErrorMessage::qtHandler(), Q3Process::start(), and QX11Data::xdndSetup().

00101 {
00102     QVFuncList *list = postRList();
00103     if (!list)
00104         return;
00105     list->prepend(p);
00106 }

Here is the call graph for this function:

QString qAppName (  ) 

Definition at line 306 of file qcoreapplication.cpp.

References QCoreApplicationPrivate::checkInstance(), and QCoreApplication::instance().

Referenced by QWidgetPrivate::create_sys(), and sm_performSaveYourself().

00307 {
00308     if (!QCoreApplicationPrivate::checkInstance("qAppName"))
00309         return QString();
00310     return QCoreApplication::instance()->d_func()->appName();
00311 }

Here is the call graph for this function:

Q_CORE_EXPORT uint qGlobalPostedEventsCount (  ) 

Definition at line 132 of file qcoreapplication.cpp.

References QThreadData::current(), QThreadData::postEventList, and QList< T >::size().

Referenced by QEventDispatcherX11::hasPendingEvents(), and QEventDispatcherUNIX::hasPendingEvents().

00133 {
00134     return QThreadData::current()->postEventList.size();
00135 }

Here is the call graph for this function:

void qRemovePostRoutine ( QtCleanUpFunction  p  ) 

Definition at line 108 of file qcoreapplication.cpp.

References QList< T >::removeAll().

Referenced by Q3ProcessManager::removeMe(), and QGLCMapCleanupHandler::~QGLCMapCleanupHandler().

00109 {
00110     QVFuncList *list = postRList();
00111     if (!list)
00112         return;
00113     list->removeAll(p);
00114 }

Here is the call graph for this function:

void Q_CORE_EXPORT qt_call_post_routines (  ) 

Definition at line 116 of file qcoreapplication.cpp.

References QList< T >::isEmpty(), and QList< T >::takeFirst().

Referenced by QApplication::~QApplication(), and QCoreApplication::~QCoreApplication().

00117 {
00118     QVFuncList *list = postRList();
00119     if (!list)
00120         return;
00121     while (!list->isEmpty())
00122         (list->takeFirst())();
00123 }

Here is the call graph for this function:

void qt_register_signal_spy_callbacks ( const QSignalSpyCallbackSet callback_set  ) 

Definition at line 88 of file qcoreapplication.cpp.

References qt_signal_spy_callback_set.

Referenced by QSignalDumper::endDump(), and QSignalDumper::startDump().

00089 {
00090     qt_signal_spy_callback_set = callback_set;
00091 }

void qt_set_current_thread_to_main_thread (  ) 

Definition at line 138 of file qcoreapplication.cpp.

References QThread::currentThread(), and QCoreApplicationPrivate::theMainThread.

Referenced by QInternal::callFunction().

Here is the call graph for this function:

void Q_CORE_EXPORT qt_startup_hook (  ) 

Definition at line 93 of file qcoreapplication.cpp.

Referenced by QCoreApplication::init().

00094 {
00095 }

void set_winapp_name (  ) 

Referenced by QCoreApplication::init().


Variable Documentation

Qt::HANDLE qt_application_thread_id = 0

Definition at line 150 of file qcoreapplication.cpp.

Referenced by QCoreApplicationPrivate::QCoreApplicationPrivate(), and QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate().

QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set = { 0, 0, 0, 0 }

Definition at line 86 of file qcoreapplication.cpp.

Referenced by QMetaObject::activate(), and qt_register_signal_spy_callbacks().


Generated on Thu Mar 15 12:38:28 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1