@@ -11,7 +11,7 @@ static HHOOK s_hHook;
1111LRESULT CALLBACK msgFilterProc (int nCode, WPARAM wParam, LPARAM lParam)
1212{
1313 if (qApp) {
14- qApp->sendPostedEvents (0 , - 1 );
14+ qApp->sendPostedEvents ();
1515 }
1616 return CallNextHookEx (s_hHook, nCode, wParam, lParam);
1717}
@@ -41,16 +41,19 @@ static void msgHandler(QtMsgType type, const QMessageLogContext &contect, const
4141 }
4242}
4343
44- QVstApplication* QVstApplication::createInstance (Qt::HANDLE handle)
44+ QVstApplication* QVstApplication::createInstance (Qt::HANDLE handle, Flags flags )
4545{
4646 QApplication *pGuiApp = qApp;
4747 if (pGuiApp) {
4848 return static_cast <QVstApplication*>(pGuiApp);
4949 }
5050
5151 int argc = 0 ;
52- QVstApplication *pInstance = new QVstApplication (argc, nullptr , handle);
53- qInstallMessageHandler (msgHandler);
52+ QVstApplication *pInstance = new QVstApplication (argc, nullptr , handle, flags);
53+ if ((flags & Flag_CreateConsole) != 0 ) {
54+ // Install log messages handler only if there is a console
55+ qInstallMessageHandler (msgHandler);
56+ }
5457
5558 return pInstance;
5659}
@@ -60,15 +63,15 @@ QVstApplication* QVstApplication::instance()
6063 return static_cast <QVstApplication*>(qApp);
6164}
6265
63- QVstApplication::QVstApplication (int &argc, char **argv, Qt::HANDLE handle)
66+ QVstApplication::QVstApplication (int &argc, char **argv, Qt::HANDLE handle, Flags flags )
6467 : QApplication(argc, argv)
6568{
6669 m = new Private;
6770 m->handle = handle;
6871 m->pConsole = nullptr ;
69- # ifdef QVST_CONSOLE
70- m->pConsole = new QVstConsole (this );
71- # endif
72+ if ((flags & Flag_CreateConsole) != 0 ) {
73+ m->pConsole = new QVstConsole (this );
74+ }
7275
7376#ifdef WIN32
7477 s_hHook = SetWindowsHookEx (WH_GETMESSAGE, msgFilterProc, 0 , GetCurrentThreadId ());
0 commit comments