Opened 17 years ago
Closed 17 years ago
#1610 closed bug (fixed)
Error opening an empty file
Reported by: | humdinger | Owned by: | stippi |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | Applications/StyledEdit | Version: | R1/pre-alpha1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
This is on hrev22860 in vmware. Opening an empty file shows this error: "Error loading "[filename]": Bad argument type passed to function". Bummer. Dismissing this alertbox opens the file nontheless.
Attachments (2)
Change History (9)
comment:1 by , 17 years ago
by , 17 years ago
Attachment: | stxt-fix.patch added |
---|
Fix for the STXT translator (without the extra newline)
comment:2 by , 17 years ago
It turns out that it was caused by the STXT translator, the file_ascmagic function threw away the file if it's size was 0 or 1 bytes, even if the file's type was identified.
I removed that line, now it works as it should.
comment:3 by , 17 years ago
Thanks for that quick fix, Váradi! If only we could find someone to apply the patch... :) wink,wink, nudge,nudge
comment:4 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I didn't apply the patch quite as is, but I assume the bug it now fixed. :-) Thanks for investigating it! Fixed in hrev22892.
comment:6 by , 17 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Thanks for working on it, but the bug is still there.
I did the following:
~> touch Text ~> StyledEdit Text
And the popup is still there. However, if the file is 1 byte long, it works now :)
The function looks_ascii(...) returns true for the empty buffer, so the second condition won't even be evaluated.
I'm attaching a patch that separates the null bytes condition, and defaults it to UTF-8. Now it really works as it should.
by , 17 years ago
Attachment: | stxt-fix-nullbytes.patch added |
---|
A patch separating the (nBytes == 0) condition.
comment:7 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Thanks again for checking! Applied your patch in hrev22895.
There's more to it!
StyledEdit also fails to load files with only 1 character in them. I've traced it, and the bug seems to show up in BTranslationUtils::GetStyledText, where the following call fails: (src/kits/translation/TranslationUtils.cpp, line 345)