Skip to content
New issue

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

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

Already on GitHub? # to your account

Change filename to varname algorithm, add try/catch blocks around image processing thread #1419

Merged
merged 2 commits into from
Feb 21, 2024

Conversation

Randalphwa
Copy link
Collaborator

The main focus of this PR is to change the filename to varname conversion. I encountered a situation where the entire filename was UTF8, and conversion failed completely, creating a varname of _svg. Part os this was due to wxString::Format, but even fixing that resulted in tripling the varname instead of the expected doubling. The new algorithm solves makes the varname a bit shorter, and also solves the UTF8 issue. The name is unique, but for UTF8, it will off course bear no resemblance to the original filename.

The second part of this PR adds try/catch around thrd_collect_img_headers.join(); -- I'm running into a crash in the thread. This won't solve the crash, but should help to find the source of the problem. Once found, it still makes sense to leave the try/catch in place since it won't have any noticeable effect on performance.

A completely UTF8 filename could triple it's size since very UTF8 character was
preceeded by an '_'. In addition, a completely UTF8 filename would not convert
anything.

The new algorithm uses snprintf to convert to a hex digit, and only adds a
preceeding '_' character if the preceeding filename character was *not* a
UTF8 character.
We need to catch the exceptions right when they occur.
@Randalphwa Randalphwa merged commit 692c9f1 into main Feb 21, 2024
@Randalphwa Randalphwa deleted the exceptions branch February 21, 2024 18:43
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant