Opened 12 years ago

Closed 16 months ago

Last modified 16 months ago

#9064 closed bug (fixed)

An invalidated BView does not draw to a BBitmap

Reported by: axeld Owned by: nobody
Priority: high Milestone: R1/beta5
Component: Servers/app_server Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

When you have the following construct, nothing will ever be drawn to the bitmap:

	BBitmap* bitmap = new BBitmap(frame, B_RGBA32, true);
	BView* view = new BView(bitmap->Bounds(), NULL, 0, B_WILL_DRAW);
	bitmap->AddChild(view);

	if (view->LockLooper()) {
		view->Invalidate();
		view->SetHighColor(225, 225, 225, 128);
		view->FillRect(view->Bounds());

		view->UnlockLooper();
	}

If you remove the Invalidate(), the drawing operation is performed as expected. Needless to say, the code above worked fine under BeOS.

Attachments (1)

DrawBitmapTestModified.cpp (1.3 KB ) - added by Jim906 16 months ago.
Reproduces bug

Download all attachments as: .zip

Change History (5)

comment:1 by axeld, 7 years ago

Owner: changed from axeld to nobody
Status: newassigned

by Jim906, 16 months ago

Attachment: DrawBitmapTestModified.cpp added

Reproduces bug

comment:2 by Jim906, 16 months ago

I think the problem relates to the fact that BBitmap::fWindow cannot receive messages because it is an offscreen BWindow, which means Run is never called.

BView::Invalidate sends an AS_VIEW_INVALIDATE_RECT message to the OffscreenWindow that corresponds to fWindow. The OffscreenWindow, in response, sends back an _UPDATE_ message. Since fWindow can't receive messages, it does not make the expected reply (AS_BEGIN_UPDATE) to the OffscreenWindow. This leaves the OffscreenWindow in a state where fUpdateRequested is true and fInUpdate is false. In this state, Window::GetEffectiveDrawingRegion will decide that the invalidated area can't be drawn to.

This situation can be avoided if OffscreenWindow's base member Window::fUpdatesEnabled is false, because then Window::_SendUpdateMessage won't send the _UPDATE_ message and won't set fUpdateRequested to true. Suggested patch: https://review.haiku-os.org/c/haiku/+/5967.

comment:3 by pulkomandy, 16 months ago

Milestone: R1R1/beta5
Resolution: fixed
Status: assignedclosed

Fixed in hrev56677.

in reply to:  3 comment:4 by kim1963, 16 months ago

Replying to pulkomandy:

Fixed in hrev56677.

Should this be considered for beta4?

Note: See TracTickets for help on using tickets.