Skip to content

miroil/display_listener_wrapper: Do not store a reference to shared_ptr#4953

Open
muhammad23012009 wants to merge 1 commit into
canonical:mainfrom
muhammad23012009:display_listener_wrapper_fix
Open

miroil/display_listener_wrapper: Do not store a reference to shared_ptr#4953
muhammad23012009 wants to merge 1 commit into
canonical:mainfrom
muhammad23012009:display_listener_wrapper_fix

Conversation

@muhammad23012009
Copy link
Copy Markdown
Contributor

Fixes the reference getting corrupted in QtMir.

Checklist

  • Tests added and pass
  • Adequate documentation added
  • (optional) Added Screenshots or videos

Fixes the reference getting corrupted in QtMir.
Copilot AI review requested due to automatic review settings May 21, 2026 09:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a lifetime/ownership bug in the miroil QtMir integration by ensuring DisplayListenerWrapper owns its std::shared_ptr<mir::compositor::DisplayListener> instead of storing a reference to a shared_ptr that can dangle and become corrupted.

Changes:

  • Replace the std::shared_ptr<...> const& member with a by-value std::shared_ptr<...> member in DisplayListenerWrapper to make ownership/lifetime safe.


private:
std::shared_ptr<mir::compositor::DisplayListener> const& display_listener;
std::shared_ptr<mir::compositor::DisplayListener> display_listener;
@AlanGriffiths
Copy link
Copy Markdown
Contributor

I'm curious: how is this class useful? (I agree the shared_ptr& is questionable, but I'd expect QtMir to implement DisplayListener, not call methods on it.)

@muhammad23012009
Copy link
Copy Markdown
Contributor Author

I'm curious: how is this class useful? (I agree the shared_ptr& is questionable, but I'd expect QtMir to implement DisplayListener, not call methods on it.)

DisplayListener is implemented by mir::server::shell, which is returned to QtMir as a result of miroil::SetCompositor. As DisplayListener itself is part of the internal API, miroil is used to alleviate that

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.

3 participants