* reintroduce member fOffscreen which got removed in r2917

* check if locking the offscreen window succeeds before calling delete on it
* don't return offscreen windows in CountWindows and WindowAt (works now as on R5)

  fixes ticket 1522, 1591, 1946, 2318 and propably more

  While creating an BBitmap in BApplication the bitmaps window looper would
  be added to the applications gLooperList, thus calling Quit() on that window
  and later delete on a stale window pointer in BBitmaps dtor. The Lock() check
  would fix the problem, but tests on R5 have shown that BApplication hides the
  offscreen window in CountWindows() and WindowAt().



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28236 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Karsten Heimrich 2008-10-19 12:23:18 +00:00
parent a02979bb3f
commit d751323939
4 changed files with 15 additions and 15 deletions

View File

@ -347,7 +347,7 @@ private:
BList fShortcuts;
int32 fTopViewToken;
bool fUpdateRequested;
bool _unused3;
bool fOffscreen;
bool fIsFilePanel;
bool _unused4;
bigtime_t fPulseRate;

View File

@ -1478,7 +1478,7 @@ BApplication::_CountWindows(bool includeMenus) const
uint32 count = 0;
for (int32 i = 0; i < gLooperList.CountLoopers(); i++) {
BWindow* window = dynamic_cast<BWindow*>(gLooperList.LooperAt(i));
if (window != NULL && (includeMenus
if (window != NULL && !window->fOffscreen && (includeMenus
|| dynamic_cast<BMenuWindow *>(window) == NULL)) {
count++;
}
@ -1498,8 +1498,8 @@ BApplication::_WindowAt(uint32 index, bool includeMenus) const
uint32 count = gLooperList.CountLoopers();
for (uint32 i = 0; i < count && index < count; i++) {
BWindow* window = dynamic_cast<BWindow*>(gLooperList.LooperAt(i));
if (window == NULL || (!includeMenus
&& dynamic_cast<BMenuWindow *>(window) != NULL)) {
if (window == NULL || window != NULL && window->fOffscreen
|| (!includeMenus && dynamic_cast<BMenuWindow *>(window) != NULL)) {
index++;
continue;
}

View File

@ -237,10 +237,8 @@ BBitmap::BBitmap(const BBitmap& source)
*/
BBitmap::~BBitmap()
{
if (fWindow != NULL) {
fWindow->Lock();
if (fWindow && fWindow->Lock())
delete fWindow;
}
_CleanUp();
}
@ -1079,14 +1077,14 @@ BBitmap::_InitObject(BRect bounds, color_space colorSpace, uint32 flags,
// So at this point the bitmap has to be already cleared to white.
// Better move the above code to the server so the problem looks more clear.
if (flags & B_BITMAP_ACCEPTS_VIEWS) {
fWindow = new(std::nothrow) BWindow(Bounds(), fServerToken);
if (fWindow) {
// A BWindow starts life locked and is unlocked
// in Show(), but this window is never shown and
// it's message loop is never started.
fWindow->Unlock();
} else
fInitError = B_NO_MEMORY;
fWindow = new(std::nothrow) BWindow(Bounds(), fServerToken);
if (fWindow) {
// A BWindow starts life locked and is unlocked
// in Show(), but this window is never shown and
// it's message loop is never started.
fWindow->Unlock();
} else
fInitError = B_NO_MEMORY;
}
}
}

View File

@ -2554,6 +2554,7 @@ BWindow::_InitData(BRect frame, const char* title, window_look look,
fLastViewToken = B_NULL_TOKEN;
// TODO: other initializations!
fOffscreen = false;
// Create the server-side window
@ -2583,6 +2584,7 @@ BWindow::_InitData(BRect frame, const char* title, window_look look,
} else {
fLink->StartMessage(AS_CREATE_OFFSCREEN_WINDOW);
fLink->Attach<int32>(bitmapToken);
fOffscreen = true;
}
fLink->Attach<BRect>(fFrame);