Skip to content

Move listener declaration out of the lambda.#165

Open
ArekMiszcz wants to merge 1 commit intoheroiclabs:masterfrom
ArekMiszcz:example_fault
Open

Move listener declaration out of the lambda.#165
ArekMiszcz wants to merge 1 commit intoheroiclabs:masterfrom
ArekMiszcz:example_fault

Conversation

@ArekMiszcz
Copy link
Copy Markdown

@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
Copy Markdown

CLAassistant commented May 20, 2025

CLA assistant check
All committers have signed the CLA.

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

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.

5 participants