Log icon indicating copy to clipboard operation
Log copied to clipboard

[Log 2.0 Alpha] Fatal Crash with settings_changed signal in Godot 4.4

Open HelloImKevo opened this issue 11 months ago • 1 comments

When I installed the Log 2.0 Alpha addon, Godot 4.4 on macOS was crashing whenever I tried to save any script; this is the output I was able to get:

ERROR: Signal 'settings_changed' is already connected to given callable 'GDScript::sync_project_settings' in that object.
WARNING: core/os/thread.cpp:107 - A Thread object is being destroyed without its completion having been realized.
WARNING: Please call wait_to_finish() on it to ensure correct cleanup.
ERROR: Signal 'settings_changed' is already connected to given callable 'GDScript::sync_project_settings' in that object.
WARNING: core/os/thread.cpp:107 - A Thread object is being destroyed without its completion having been realized.
WARNING: Please call wait_to_finish() on it to ensure correct cleanup.
ERROR: Signal 'settings_changed' is already connected to given callable 'GDScript::sync_project_settings' in that object.
WARNING: core/os/thread.cpp:107 - A Thread object is being destroyed without its completion having been realized.
WARNING: Please call wait_to_finish() on it to ensure correct cleanup.
ERROR: modules/gdscript/gdscript_vm.cpp:1327 - Condition ' !gdscript ' is true. Breaking..:
ERROR: res://addons/logger/_LogInternalPrinter.gd:130 - Internal script error! Opcode: 20 (please report).

I tweaked two lines of code in _LogInternalPrinter.gd, and this seems to have fixed the issue:

static func _static_init() -> void:
  var queue_size = _settings._ensure_setting_exists(_settings.LOG_QUEUE_SIZE_KEY, _settings.LOG_QUEUE_SIZE_DEFAULT_VALUE)
  BB_CODE_REMOVER_REGEX.compile("\\[(lb|rb)\\]|\\[.*?\\]")
  
  if not ProjectSettings.settings_changed.is_connected(LogStream.sync_project_settings):
    ProjectSettings.settings_changed.connect(LogStream.sync_project_settings)
static func _cleanup():
  _log_mutex.lock()
  _is_quitting = true
  _log_mutex.unlock()
  # Ensure the thread is still running before calling wait_to_finish()
  if _log_thread.is_started():
    _log_thread.wait_to_finish()

HelloImKevo avatar Mar 10 '25 17:03 HelloImKevo

Nice. This improvement will come in Log 2.0 Alpha 2, which I'm currently working on.

albinaask avatar Mar 22 '25 10:03 albinaask