Closing a qmainwindow application on Windows



  • Hi All,

    I am developing a network qt application (client-server application). In fact, I 'm using QTcpSocket to communicate between the clients and the server.

    The application works well, but when i try to close the client interface on Windows, I have a runtime problem. Exactly, I have this problem: his application has requested the runtime to terminate it in an unusual way.

    I tried to re-implement the closeEvent function by closing the client socket on closing the main window, but i still have the same problem.

    How can i fix this bug?
    Any help would be appreciated.


  • Moderators

    @fahmouch
    Did you close all communication through QTcpSocket and delete them properly?
    It depends how you set out the sockets. It might be that they are still receiving information while you close the application.



  • Yes, i'm closing the client socket using the close function.

    There is any other method to delete them properly?



  • Why do you think this is related to your network programming? Could be anything.



  • Hi,

    as @Wieland said, probably the problem in not related to TCP Socket.
    Can you post the code of your Window? Have you tried to debug??



  • 90% of such problems occur when people provide parent to the QObject (usually QWidget ) derived classes allocated on the heap.
    As result their objects are deleted twice which causes termination.



  • @Wieland

    I tried to execute my application without communication between the client and the server. And by doing that, i haven't any problem on closing the application.

    I think that the cause of this problem that the runtime still receives responses to the clients, that's why, it couldn't close properly this application.

    Have you any idea how to fix this problem?



  • Did you check for missed exceptions? Maybe some of your network code throws something if your application is closing. A unhandled exceptions can causes the error you described in your first post.



  • @fahmouch Without code and/or crash dump is very hard for us to help you


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.