cnjinhao / nana

a modern C++ GUI library
https://nana.acemind.cn
Boost Software License 1.0
2.29k stars 331 forks source link

Font use count is 2 on exit throwing exception #679

Open LokiNinja opened 8 months ago

LokiNinja commented 8 months ago

Dear god....WHY WHY do you mixed shared pointers with regular pointers. You explicitly check a shared ptr use count on exit and throw an exception but WHY? The shared ptr will clean that up anyways. If its a C pointer then there is NO reason to use a shared ptr...either way its an error. It's causing an exception on exit for me. It's the platform font shared ptr...In particular, its this that is throwing exception image

Please do not do that...Just clean up in destructor which will happen with the reset call after the if

Just use a shared pointer with a custom allocator that cleans it up correctly

EDIT: I think you have a copy constructor for label class that is no good. It works fine as long as I don't pass s label to another class

cnjinhao commented 8 months ago

It is necessary to check the use count. In X Window, all font objects should be deleted before deleting storage, otherwise it crashes.

All widgets are not copyable and moveable.

LokiNinja commented 7 months ago

Hey Jinhao,

Its possible that there may be a copy happening somewhere that I am not aware of. I would recommend that you use '= delete' for copy and move constructors/assignment operators. That way this would be a compile error instead of a runtime error and it may show me where the copy is happening so that I can fix it in my code.

-Thanks,

Thomas