diff options
author | David Faure <faure+bluesystems@kde.org> | 2013-01-14 12:58:31 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-15 14:58:35 +0100 |
commit | d147285d644157bc12487584578b5389b56eea31 (patch) | |
tree | b035b6ca02197e8f0a2df6c10a89f51ecf1f50e0 /src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp | |
parent | 3a1f1aecf9b4ef05fd162cd60e06214dc28922b6 (diff) |
Add Q_COREAPP_STARTUP_FUNCTION macro.
This is necessary for initializing things in a library, which require
a QCoreApplication instance (unlike Q_CONSTRUCTOR_FUNCTION, which runs
before that). Example use cases: KCrash (segv handler), and KCheckAccelerators
(debugging tool triggered by magic key combination).
Change-Id: I5f4c4699dd4d21aea72b007989ba57467e86ed10
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp')
-rw-r--r-- | src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp index e677797323..6029c0e4ec 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp @@ -57,7 +57,14 @@ foreach (const QString &path, app.libraryPaths()) //! [3] +// Called once QCoreApplication exists +static void preRoutineMyDebugTool() +{ + MyDebugTool* tool = new MyDebugTool(QCoreApplication::instance()); + QCoreApplication::instance()->installEventFilter(tool); +} +Q_COREAPP_STARTUP_FUNCTION(preRoutineMyDebugTool) //! [3] |