Skip to content

Move listener declaration out of the lambda. #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ArekMiszcz
Copy link

@ArekMiszcz ArekMiszcz commented May 20, 2025

With current shape, an example is throwing segmentation fault error so people rising new issues.
This simple fix solving that problem into this example.

@CLAassistant
Copy link

CLAassistant commented May 20, 2025

CLA assistant check
All committers have signed the CLA.

@novabyte novabyte requested review from Copilot and RicardRC May 20, 2025 12:01
Copy link

@Copilot 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 addresses a segmentation fault error by moving the declaration of the NRtDefaultClientListener out of the lambda, thereby ensuring its lifetime extends for the duration of the asynchronous callbacks.

  • Moved listener declaration to the outer scope.
  • Updated lambda capture list to include the listener.
Comments suppressed due to low confidence (1)

example/main.cpp:73

  • Ensure that the listener's lifetime covers the entire duration needed for asynchronous callbacks, as capturing it by reference may lead to lifetime issues if the surrounding scope ends early.
auto loginSucceededCallback = [&done, &connectSucceededCallback, &rtErrorCallback, &client, &rtClient, &listener](Nakama::NSessionPtr session) {

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.

4 participants