Opened 18 years ago
Closed 18 years ago
#1014 closed bug (fixed)
Pages printed with StyledEdit are empty
Reported by: | laplace | Owned by: | jackburton |
---|---|---|---|
Priority: | high | Milestone: | R1 |
Component: | User Interface | Version: | R1/pre-alpha1 |
Keywords: | Cc: | laplace | |
Blocked By: | Blocking: | ||
Platform: | All |
Description
- Open Printers preflet and add a preview printer.
- Open StyledEdit and enter some text.
- Select from menu File > Print...
- Press page setup icon to open the page setup dialog and click OK.
- Press job setup icon to open the dialog and enter page range from 1 to 1 and click OK.
- Press OK.
The preview window opens, however it is empty.
I have not yet examined the problem closely. It seems BPictures are flattened to the spool file, because the file size changes depending on the amount of text in StyledEdit. Also if there is more text that does not fit on a single page, the Preview window allows to navigate to the next page (that is empty as well). So a first guess is, that the recorded pictures can not be flattened/unflattened correctly.
Change History (12)
comment:1 by , 18 years ago
Cc: | added |
---|
comment:2 by , 18 years ago
Owner: | changed from | to
---|
comment:3 by , 18 years ago
follow-up: 5 comment:4 by , 18 years ago
I will test it today.
Could it also be a problem, that return value from BDataIO.Write()/Read() is treated as status_t instead of ssize_t, which holds the number of bytes written/read?
follow-up: 6 comment:5 by , 18 years ago
Replying to laplace:
I will test it today.
Could it also be a problem, that return value from BDataIO.Write()/Read() is treated as status_t instead of ssize_t, which holds the number of bytes written/read?
Since it tests for values < B_OK (and not != B_OK), it shouldn't be a problem. BDataIO::Write() returns a negative value on error.
comment:6 by , 18 years ago
Replying to jackburton:
Could it also be a problem, that return value from BDataIO.Write()/Read() is treated as status_t instead of ssize_t, which holds the number of bytes written/read?
Since it tests for values < B_OK (and not != B_OK), it shouldn't be a problem. BDataIO::Write() returns a negative value on error.
Actually, you are right. In BPicture::Flatten() it tests also for B_OK: int32 size = extent->Size();
status = stream->Write(&size, sizeof(size)); if (status == B_OK)
status = stream->Write(extent->Data(), extent->Size());
So the last line will never be called.
follow-up: 8 comment:7 by , 18 years ago
Anyone care to fix this? At least I could do it now, if you like :-)
follow-up: 9 comment:8 by , 18 years ago
Replying to axeld:
Anyone care to fix this? At least I could do it now, if you like :-)
Please do :)
comment:9 by , 18 years ago
In hrev20084 Axel has fixed flattening/unflattening BPictures. Unfortunately, this does not fix this bug.
Do we have unit tests for flattening/unflattening BPictures so that we can verify that at least these tests work?
comment:10 by , 18 years ago
Not yet. I was planning to add some, but at the moment I don't have access to my development machine.
comment:11 by , 18 years ago
Btw I just noticed that the server part of the AS_CREATE_PICTURE and AS_DOWNLOAD_PICTURE handlers (used in BPicture::Flatten()/Unflatten() have some TODOs related to nested BPictures. Worth having a look too.
comment:12 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
app_server was writing beyond allocated memory in the AS_CREATE_PICTURE handler, inside ServerApp. I fixed this in hrev20285. Preview now somewhat works. Closing...
I cannot commit or test anything right now... but I've had a quick look at BPicture, and I think I found the problem:
In BPicture::Flatten(), we do: [cut] int32 count = extent->CountPictures(); if (count > 0) {
[cut]
And then, in BPicture::Unflatten(), we do:
[cut] int32 count = 0; status_t status = stream->Read(&count, sizeof(count)); [cut]
We should always write the count in BPicture::Flatten(), even if it is 0, otherwise BPicture::Unflatten() won't work correctly.