diff options
| author | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-04-04 15:20:55 +0900 |
|---|---|---|
| committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-05-01 13:44:49 +0900 |
| commit | 8141b881e3f6088c9980c1ee41f8e926e18cc208 (patch) | |
| tree | 0d80b1d97e960fcb165f0fc49f2c77a5523bb438 /src/kernel/qeventloop_x11_glib.cpp | |
| parent | 73c9765982a42ac7b1eb1608b8d684701dc0b9d6 (diff) | |
| download | tqt-8141b881e3f6088c9980c1ee41f8e926e18cc208.tar.gz tqt-8141b881e3f6088c9980c1ee41f8e926e18cc208.zip | |
Correctly release glib mainloop and gsource, to avoid memory leaks
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 08a71c8f8d2d73bc1ba7d6b2a58b9ce30184c471)
Diffstat (limited to 'src/kernel/qeventloop_x11_glib.cpp')
| -rw-r--r-- | src/kernel/qeventloop_x11_glib.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/kernel/qeventloop_x11_glib.cpp b/src/kernel/qeventloop_x11_glib.cpp index 4b44fe8f2..a13dbeebf 100644 --- a/src/kernel/qeventloop_x11_glib.cpp +++ b/src/kernel/qeventloop_x11_glib.cpp @@ -226,7 +226,7 @@ void TQEventLoop::init() printf("inside init(1)\n"); #endif - g_main_loop_new (d->ctx, 1); + d->mainloop = g_main_loop_new (d->ctx, 1); g_source_attach( (GSource*)qtGSource, d->ctx ); d->gSource = (GSource*)qtGSource; @@ -258,10 +258,22 @@ void TQEventLoop::cleanup() // cleanup the X11 parts of the event loop d->xfd = -1; + // stop polling the GSource + g_source_remove_poll(d->gSource, &d->threadPipe_gPollFD); + g_source_remove_poll(d->gSource, &d->x_gPollFD); + g_source_destroy(d->gSource); + + // unref the main loop + g_main_loop_unref(d->mainloop); + d->mainloop = nullptr; + + // unref the gsource + g_source_unref(d->gSource); + d->gSource = nullptr; + // unref the main context g_main_context_unref(d->ctx); - - // todo: destroy gsource + d->ctx = nullptr; } bool TQEventLoop::processEvents( ProcessEventsFlags flags ) |
