From d147285d644157bc12487584578b5389b56eea31 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 14 Jan 2013 12:58:31 +0100 Subject: 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 Reviewed-by: Thiago Macieira --- .../doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp') 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] -- cgit v1.2.3