-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Duplicate Dialog return value avoids mistakes reuse reference #40
Conversation
source/nijigenerate/package.d
Outdated
@@ -129,7 +129,7 @@ void incClearImguiData() { | |||
Returns the current project path | |||
*/ | |||
string incProjectPath() { | |||
return currProjectPath; | |||
return currProjectPath.dup; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't see entire part of the code now, but it seems duplicating every time in incProjectPath might be heavy operation if it is used in update loop of UI. if that happens, string duplication should be called at client side and only if it should be duplicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that this function is only called when file access, so encapsulates and protects the internal resources of incProjectPath
.
Additionally, the issue appears to be caused by incShowSaveDialog()
and incShowOpenDialog()
, as they may be called in other places as well. I will apply a patch there too. that only called once when the user needs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found incProjectPath is called in every update loop in incCheckAutosave.
So dup should not be called inside incProjectPath.
I still don't understand why this dup is needed yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the root cause is that after users save as new .inx and export png or videos, they share the string returned by incShowSaveDialog()
leading to the two issues mentioned above.
The crash on macOS differ from those on Windows, windows is access denied, macos indicates that it is a directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cause the user to overwrite the incProjectPath after exported the png.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the d language cast is using the c_string memory address, I'm not sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bug can also be reproduced like this
- open inx
- save as new inx
- export png or video
- Ctrl+s
You can see that the saved path is incorrect, but it will not crash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incCheckAutosave seems to be called per frame, that may need to be modified
I couldn't reproduce this bug by myself. (MacOS) Or some sort of buffer overflow happens. |
@seagetch macos can be reproduced successfully, you may need to shorten the interval or set a hotkey invoke
In this case, I first "save as" and then export an "未命名" png. then call the autosave function This bug can also be reproduced like this
Make sure the two names are different The export name seems to need to be shorter than inx to reproduce
|
case 2
|
inochi-creator issue
Inochi2D/inochi-creator#392
Inochi2D/inochi-creator#378
Reproduce the crash
upstream pr: Inochi2D/inochi-creator#393