imjp94 / gd-plug

Minimal plugin manager for Godot
MIT License
217 stars 15 forks source link

Warning: Thread destroyed without wait_to_finish() called #11

Closed lihop closed 1 year ago

lihop commented 1 year ago

Another small issue I'm facing is this warning message being printed after running gd-plug:

WARNING: A Thread object has been destroyed without wait_to_finish() having been called on it. Please do so to ensure correct cleanup of the thread.
     at: ~Thread (core/os/thread.cpp:116)

While the plugin seems to work fine, it would be nice to not see this warning message every time I run it.

Simply adding a call to threadpool._flush_threads() in _finalize() resolves the warning. However, I notice that _flush_threads() is a private method, so I'm not sure if this is how you want to fix it.

diff --git a/addons/gd-plug/plug.gd b/addons/gd-plug/plug.gd
index 088a203..a90d47f 100644
--- a/addons/gd-plug/plug.gd
+++ b/addons/gd-plug/plug.gd
@@ -94,6 +94,7 @@ func _idle(delta):

 func _finalize():
        _plug_end()
+       threadpool._flush_threads()
        logger.info("Finished, elapsed %.3fs" % ((Time.get_ticks_msec() - _start_time) / 1000.0))

 func _on_updated(plugin):

Again, thanks for your hard work on this fantastic plugin!

imjp94 commented 1 year ago

Thanks for the fix! I think I will first check what is causing the warnings since it doesn't happen in 3.x, otherwise, I might consider simply making _flush_threads a public method.