Skip to content

[RFC]Refactor: remove some action that passing this ptr as callback param in constructor#5004

Open
Mrpaoo wants to merge 1 commit into
Alexays:masterfrom
Mrpaoo:fix-module_make
Open

[RFC]Refactor: remove some action that passing this ptr as callback param in constructor#5004
Mrpaoo wants to merge 1 commit into
Alexays:masterfrom
Mrpaoo:fix-module_make

Conversation

@Mrpaoo
Copy link
Copy Markdown
Contributor

@Mrpaoo Mrpaoo commented Apr 23, 2026

Related issue #4995 , It's been danger to pass this as a callback ptr or do something that may throw error in constructor. its recommend to call init() after construct. so i declare two func in Class AModule void init() to register callback pass this to framework, virtual void do_init() derived class can implement it and put error-throw action here rather than in constructor.And init() would be call after factory.MakeModule(), inside init() then it call do_init()

    module = factory.makeModule(ref, pos);
    module->init();
void AModule::init() {
  // here are the point where obj is fully constructed
  // we can do sth like connect signal that requires well constructed object
  do_init();
  .....

It is noticed that i only modify the hyprland/workspaces and AModule consider that overhaul every module is danger and i wasnt pretty sure if the community appreciate this refactor. So i need some advice about it. If it work, i can refactor the rest of them

And i have no idea if it need some test code, and idk how to test the situation like this, so yes, please let me know if u have better idea!

@Mrpaoo Mrpaoo changed the title [RFC]Refactor: remove some action that may throw error from constructor to… [RFC]Refactor: remove some action that passing this ptr as callback param in constructor Apr 27, 2026
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.

1 participant