Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    Closing an application without killing main loop

    Reply
    Page 2 of 3 | Prev |   1   2   3   | Next
    coderus | # 11 | 2013-12-04, 20:10 | Report

    install event filter

    Edit | Forward | Quote | Quick Reply | Thanks

     
    vranki | # 12 | 2013-12-04, 20:10 | Report

    Originally Posted by xerxes2 View Post
    Why are you calling eventLoop.exec()? You already has one mainloop running so just put your cleanup code in the aboutToQuit callback instead. The mainloop will not exit before the aboutToQuit callback returns. There was a bug in earlier sdk but in the latest version it works just fine.
    The app is single threaded - everything happens in the main event loop. Everything (signals, slots, timers, networking) is frozen during aboutToQuit() call. That's why i'd need a second event loop to do processing without exiting aboutToQuit() in main thread.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    vranki | # 13 | 2013-12-04, 20:13 | Report

    Originally Posted by coderus View Post
    install event filter
    ..to which event in which object? As i wrote in the original post, i already tried it with no success.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    xerxes2 | # 14 | 2013-12-04, 20:26 | Report

    Originally Posted by vranki View Post
    The app is single threaded - everything happens in the main event loop. Everything (signals, slots, timers, networking) is frozen during aboutToQuit() call. That's why i'd need a second event loop to do processing without exiting aboutToQuit() in main thread.
    Afaik you can only have one mainloop in both gtk and qt. I've never heard anything about having two.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    vranki | # 15 | 2013-12-04, 20:35 | Report

    I think the reason for newly started main loop is in qwaylandeventthread.cpp line 37:

    https://qt.gitorious.org/qt/qtwaylan...thread.cpp#L37

    When app window is closed, the Wayland connection is broken and if something (in the new mainloop?) calls readWaylandEvents(), the process is killed.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    coderus | # 16 | 2013-12-04, 20:59 | Report

    okay, event filtering seems not to work in emulator, try:
    Code:
      app->connect( app, SIGNAL(lastWindowClosed()), app, SLOT(quit()) );
      app->connect( app, SIGNAL(aboutToQuit()), app, SLOT(quit()) );
    and why not to use main class destructor for this purpose?

    and
    Code:
        int retVal = app->exec();
        qDebug() << "App exiting with code:" << QString::number(retVal);
        //you can do whatever here
        return retVal;

    Edit | Forward | Quote | Quick Reply | Thanks

     
    vranki | # 17 | 2013-12-04, 21:28 | Report

    Originally Posted by coderus View Post
    and why not to use main class destructor for this purpose?

    Code:
        //you can do whatever here
    Signals, slots, networking, and all other asynchronous stuff does not work without a event loop. And i need those.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    coderus | # 18 | 2013-12-04, 21:32 | Report

    what about other methods?

    Edit | Forward | Quote | Quick Reply | Thanks

     
    uvatbc | # 19 | 2013-12-05, 00:04 | Report

    Originally Posted by vranki View Post
    Does not work - the main loop still exits. Same with Harmattan.
    Well thats surprising - I've been using setQuitOnLastWindowClosed in Maemo, Harmattan, Windows and desktop Linux at least for the last two years in qgvdial to achieve exactly what you need: Running the application in the background.

    https://code.google.com/p/qgvdial/so...k/src/main.cpp

    Edit | Forward | Quote | Quick Reply | Thanks

     
    vranki | # 20 | 2013-12-05, 12:19 | Report

    Originally Posted by uvatbc View Post
    Well thats surprising - I've been using setQuitOnLastWindowClosed in Maemo, Harmattan, Windows and desktop Linux at least for the last two years in qgvdial to achieve exactly what you need: Running the application in the background.

    https://code.google.com/p/qgvdial/so...k/src/main.cpp
    Ok, i think i'll need to create a simple test application for this issue.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Page 2 of 3 | Prev |   1   2   3   | Next
vBulletin® Version 3.8.8
Normal Logout