Opened 13 years ago

Closed 13 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 by laplace, 13 years ago

Cc: laplace added

comment:2 by axeld, 13 years ago

Owner: changed from axeld to jackburton

comment:3 by jackburton, 13 years ago

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 by laplace, 13 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?

in reply to:  4 ; comment:5 by jackburton, 13 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.

in reply to:  5 comment:6 by jackburton, 13 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.

comment:7 by axeld, 13 years ago

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

in reply to:  7 ; comment:8 by jackburton, 13 years ago

Replying to axeld:

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

Please do :)

in reply to:  8 comment:9 by laplace, 13 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 jackburton, 13 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 jackburton, 13 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 jackburton, 13 years ago

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.