Skip to content

Create centralized event registry module (register_all/unregister_all)#44

Merged
lebduska merged 5 commits into
mainfrom
copilot/create-event-registry-module
Dec 21, 2025
Merged

Create centralized event registry module (register_all/unregister_all)#44
lebduska merged 5 commits into
mainfrom
copilot/create-event-registry-module

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 21, 2025

📝 Popis

Centralizuje všechny Blender event registrace do jediného modulu events/registry.py. Idempotentní register_all() a unregister_all() funkce trackují všechny handlery a timery pro garantované vyčištění při reload/unregister addonu.

Architektura:

  • events/registry.py – jediné místo pro veškerý event wiring (handlers, timers, msgbus)
  • handlers.py – pouze definice handler funkcí, žádná registrace
  • connection.py – pouze WebSocket logika, timer management delegován na registry
  • Tracking lists (_registered_handlers, _registered_timers) zajišťují kompletní cleanup

Idempotence:

# Bezpečné volat opakovaně
registry.register_all()  # Nejdříve volá unregister_all()
registry.register_all()  # Žádné duplikáty
registry.unregister_all()  # Žádné exceptions při opakování

Registrace pattern:

# Registry trackuje vše pro cleanup
handlers_to_register = [
    (bpy.app.handlers.save_post, handlers.on_save_post),
    (bpy.app.handlers.load_post, handlers.on_load_post),
    # ...
]

for handler_list, handler_func in handlers_to_register:
    if handler_func not in handler_list:
        handler_list.append(handler_func)
        _registered_handlers.append((handler_list, handler_func))

Připraveno pro msgbus subscriptions (placeholder comments).

✅ Checklist

  • Kód odpovídá standardům projektu
  • Změny jsou zdokumentovány (CONTEXT.md, README.md)
  • Manuální testování proběhlo úspěšně (5/5 testů prošlo)
  • Build v CI prošel (syntax check OK)

🧪 Jak otestovat

  1. Nainstaluj addon v Blenderu
  2. Enable addon – všechny handlery a timer se zaregistrují (log: "Registering all event handlers via registry")
  3. Disable/enable addon opakovaně – žádné duplikáty, čisté cleanup
  4. Prověř logy: každý handler/timer zalogován při register/unregister
  5. Spusť testy: python3 tests/addon/test_registry.py -v
Original prompt

This section details on the original issue you should resolve

<issue_title>Create centralized event registry module (register_all/unregister_all)</issue_title>
<issue_description>Part of: #31

Create a single place where ALL Blender event wiring lives.

Proposed:

  • blendmate-addon/events/registry.py (or similar)
  • register_all() and unregister_all() must be idempotent
  • store references to appended handlers and msgbus owners
  • guarantee cleanup on addon reload/unregister

Acceptance criteria:

  • no handler/msgbus registration outside registry
  • unregister_all() removes everything without exceptions
  • safe to call multiple times (no duplicates / no missing removals)

Notes:

  • handlers: append/remove pairs
  • msgbus: stable owner object, clear on unregister
  • timers: keep returned handles (if needed) and stop appropriately</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 21, 2025 18:29
Co-authored-by: lebduska <11066249+lebduska@users.noreply.github.com>
Co-authored-by: lebduska <11066249+lebduska@users.noreply.github.com>
Co-authored-by: lebduska <11066249+lebduska@users.noreply.github.com>
Copilot AI changed the title [WIP] Create centralized event registry module with management functions Create centralized event registry module (register_all/unregister_all) Dec 21, 2025
Copilot AI requested a review from lebduska December 21, 2025 18:37
@lebduska lebduska marked this pull request as ready for review December 21, 2025 20:48
Copy link
Copy Markdown
Owner

Copilot: PR #44 has conflicts with main. Please rebase/merge origin/main, resolve conflicts, push, ensure CI green, then mark PR Ready for review (remove draft). Keep changes minimal; add Fixes #<issue> in PR body if missing.

1 similar comment
Copy link
Copy Markdown
Owner

Copilot: PR #44 has conflicts with main. Please rebase/merge origin/main, resolve conflicts, push, ensure CI green, then mark PR Ready for review (remove draft). Keep changes minimal; add Fixes #<issue> in PR body if missing.

@lebduska lebduska merged commit 7250274 into main Dec 21, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create centralized event registry module (register_all/unregister_all)

2 participants