Opened 12 years ago

Closed 12 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:
Has a Patch: no Platform: All

Description

  1. Open Printers preflet and add a preview printer.
  2. Open StyledEdit and enter some text.
  3. Select from menu File > Print...
  4. Press page setup icon to open the page setup dialog and click OK.
  5. Press job setup icon to open the dialog and enter page range from 1 to 1 and click OK.
  6. 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 Changed 12 years ago by laplace

Cc: laplace added

comment:2 Changed 12 years ago by axeld

Owner: changed from axeld to jackburton

comment:3 Changed 12 years ago by jackburton

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) {

status = stream->Write(&count, sizeof(count));

[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.

comment:4 Changed 12 years ago by 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?

comment:5 in reply to:  4 ; Changed 12 years ago by jackburton

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 in reply to:  5 Changed 12 years ago by jackburton

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.

comment:7 Changed 12 years ago by axeld

Anyone care to fix this? At least I could do it now, if you like :-)

comment:8 in reply to:  7 ; Changed 12 years ago by jackburton

Replying to axeld:

Anyone care to fix this? At least I could do it now, if you like :-)

Please do :)

comment:9 in reply to:  8 Changed 12 years ago by laplace

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 Changed 12 years ago by jackburton

Not yet. I was planning to add some, but at the moment I don't have access to my development machine.

comment:11 Changed 12 years ago by jackburton

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 Changed 12 years ago by jackburton

Resolution: fixed
Status: newclosed

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...

Note: See TracTickets for help on using tickets.