I'm not sure this is required. It is definitely redundant with line 115. If listen() fails, and the user of the library does NOT call listen() again, the TCP server will only stay around as long as the QHttpServer instance is around because it is parented to the QHttpServer. If the user does call listen(), the first line of the function will handle the deletion of the previous instance.