Skip to content
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

ini_filename memory references #1

Open
nurpax opened this issue Oct 21, 2024 · 1 comment
Open

ini_filename memory references #1

nurpax opened this issue Oct 21, 2024 · 1 comment

Comments

@nurpax
Copy link
Owner

nurpax commented Oct 21, 2024

This pattern probably isn't correct:

        .def_prop_rw("ini_filename",
            [](ImGuiIO& io) { return io.IniFilename; },
            [](ImGuiIO& io, nb::handle filename) {
                // TODO what about the lifetime of io.IniFilename?
                const char* fname = !filename.is_none() ? nb::cast<const char *>(filename) : nullptr;
                io.IniFilename = fname;
            },
            "ini_filename"_a.none(),
            nb::for_getter(nb::sig("def ini_filename(self, /) -> str | None")),
            nb::for_setter(nb::sig("def ini_filename(self, filename: str | None, /) -> None"))
        )

I don't think there's anything keeping the ini_filename string alive?

Perhaps ImGuiIO needs some kind of a wrapper class too? I guess it would be possible to inherit a WrappedIO from slimgui.IO and override the property access?

@nurpax
Copy link
Owner Author

nurpax commented Oct 21, 2024

See 3498089 for reference.

Defining a similar wrapper around slimgui_ext.IO would work but how to pass most of the property accesses down to the base class without breaking typing?

nurpax added a commit that referenced this issue Oct 21, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
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

No branches or pull requests

1 participant