ikskuh / kristall

Graphical small-internet client for windows, linux, MacOS X and BSDs. Supports gemini, http, https, gopher, finger.
https://kristall.random-projects.net/
GNU General Public License v3.0
742 stars 42 forks source link

Fix crash when closing gopher tab during content loading #269

Closed entropic77 closed 1 year ago

entropic77 commented 1 year ago

This only seems to happen in the GopherClient. It's easiest to reproduce the crash when downloading a large file, and closing the tab before the download has completed.

I think this happens because when the BrowserTab is closed it deletes the client, but the client has still got it's signals connected. So when the GopherClient emits 'requestProgress', the deleted BrowserTab's on_requestProgress will be called, where it calls kristall::globals(), which seems to cause the crash.

Fixed by calling this->current_handler->cancelRequest(); in the BrowserTab destructor, which will cause clients to stop emitting 'requestProgress'.

ikskuh commented 1 year ago

Can you swap the cancel and delete? Maybe the request would still access the ui which would be then already be deleted. But nice catch!

entropic77 commented 1 year ago

Good point. I have changed order of the lines.