-
Notifications
You must be signed in to change notification settings - Fork 57
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
imgui.get_io().set_ini_filename(None) crashes #41
Comments
And i still think it would be nice to change
into
if thats legal, else
so that users can simply get and set through |
This is not a bug. The signature is:
It does not expect None as a parameter. It crashes because beneath this it's a bare char* pointer. About publishing ini_filename as a readwrite member:If I publish it as read_write, like this: //.def_readonly("ini_filename", &ImGuiIO::IniFilename, "= \"imgui.ini\" // Path to .ini file (important: default \"imgui.ini\" is relative to current working dir!). Set None to disable automatic .ini loading/saving or if you want to manually call LoadIniSettingsXXX() / SaveIniSettingsXXX() functions.")
.def_readwrite("ini_filename", &ImGuiIO::IniFilename) Then, bad things happen, for example this python extract: ini = imgui.get_io().ini_filename
imgui.get_io().ini_filename = "ALLO"
ini2 = imgui.get_io().ini_filename Will crash like this:
About publishing ini_filename as a readwrite property with getter and setters:
It does work at the moment. Changing the generator to add properties is a lot of work, for a small benefit IMHO. If you really desire this change, please post a suggestion in the discussion section. I'd like to keep the number of unresolved issues to a minimum, before I communicate more about this library. |
Hmm, should this be filed with pybind then? My attempt to call should indeed be rejected, i agree with that, but it shouldn't crash. |
I understand that publishing it as a readwrite member isn't possible with the bare pointer.
This is not high priority, and my suggestion doesn't even solve the need for you to provide a manual implementation of the setter, so its not helpful from that perspective. It only provides the user with a slightly nicer (closer to imgui) and more consistent user interface. I'll post it as a suggestion. |
|
I'll close this issue for now. We'll see if we forward this to pybind11 team (but I guess they are well aware of it already) |
The solution to this one is here.
makes pybind reject None as an argument. Any raw pointer argument to a function should probably be marked with that. In this specific case however, there is a problem with this code:
This need a check for nullptr filename input, passing that to snprintf is where the crash comes from. Setting the raw pointer field this is wrapping to null is actually explicitly supported. So something like this:
would be a fixed implementation. And the same for SetLogFilename, even if the docs don't mention nullptr is supported, the implementation indeed checks for it. |
Title says it all. I changed to
imgui.get_io().set_ini_filename('')
which works fine, but guess it should error instead of crash?The text was updated successfully, but these errors were encountered: