Skip to content

Conversation

kaixiong
Copy link
Member

DisplayDriverFactory::make() currently returns driver instances in raw pointers. This patch changes it to wrap them in std::unique_ptr.

Note that the various constructors stdout_driver_new(), stdout_sdl_driver_new(), etc. still return raw pointers. The driver code are meant to be externalised into loadable SOs and I'm unsure if we can return std::unique_ptr from there.

@kaixiong kaixiong self-assigned this Feb 10, 2023
@kaixiong kaixiong requested a review from hartwork February 10, 2023 18:16
@kaixiong kaixiong added this to the 0.5.0_alpha1 milestone Feb 10, 2023
{}

~Impl ()
{}
};

Display::Display (std::string const& driver_name)
: m_impl (new Impl)
: m_impl {new Impl {DisplayDriverFactory::instance().make (driver_name, *this)}}
Copy link
Member

@hartwork hartwork Feb 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaixiong we are passing *this here while this is in the middle of construction and not ready for any use beyond maybe holding a reference or pointer to it. We are sort-of doing that already before but… do we even need that? If it's out of scope, can it be resolved later?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hartwork good catch! I forgot about this but it's definitely safe with the current code since every driver class only stores the reference during their construction. But let me think about it more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants