QApplication does not exits if last window is closed with MSVC2015 WinRT 64bit
-
Hello! The issue is that if I complile an app with Qt WinRT (alias UWP), when I close the last window, the app is not exiting.
It seems as the lastWindowClosed singal is not emitted, since neither the "CLOSED" neither the "Hello" is not printed in the app below, and the app exits with code 1.
The error is not present if I compile it as a desktop app with msvc2015.Compiler: msvc2015
Qt: 5.6.0 msvc2015 / WinRT with msvc 2015
IDE: Qt creator
OS: Windows 10Output:
qt.winrtrunner: Using the Appx profile. qt.winrtrunner: Package already installed. qt.winrtrunner: App started with process ID 7584 qt.winrtrunner: App exited with code 1
My code:
main.cpp:
#include <QApplication> #include <QMainWindow> #include <QDebug> int main(int argc, char *argv[]) { QApplication a(argc, argv); QObject::connect( &a, &QApplication::lastWindowClosed, [](){ qDebug() << "CLOSED"; } ); QMainWindow w; w.show(); auto ret = a.exec(); qDebug() << "Hello!"; return ret; }
#------------------------------------------------- # # Project created by QtCreator 2016-05-21T18:11:15 # #------------------------------------------------- QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = TEST TEMPLATE = app SOURCES += main.cpp HEADERS += FORMS +=
It has came out when I run my own project, but it is the same with this simple example.
Am I doing something wrong, or is this a bug?
Thanks! -
@Baarnus
Hello,Am I doing something wrong, or is this a bug?
The code looks perfectly fine to me. Possibly a bug or some OS idiosyncrasy. However, this:
qt.winrtrunner: App exited with code 1
Leads me to believe the app actually exits. Perhaps you just don't see the output from
qDebug
? -
Leads me to believe the app actually exits. Perhaps you just don't see the output from
qDebug
?Valid point. I have tried print something before the
a.exec()
and they are shown in the output as expected.Maybe only the winrtrunner says that the app is exited, but it is exited for other reason. I don't know.
-
@kshegunov
I checked: the process disappears from the task manager just whenqt.winrtrunner: App exited with code 1
is written into the output. So I think the process is running. I can only think that thelastWindowClosed
signal isn't emitted, which seems to me as a bug. Tomorrow I will test it on my workplace machine. -
@Baarnus said:
the process disappears from the task manager just when qt.winrtrunner: App exited with code 1 is written into the output.
This'd mean the process exits okay. So you should perhaps focus on why you can't see the output. There may be a bug somewhere with the WinRT implementation or something else, but I'd thoroughly check everything else first. For example, what happens if you use:
QTextStream out(stdout); out << "CLOSED" << endl;
instead of
qDebug() << "CLOSED";
, is this printed/visible?