diff --git a/headers/os/interface/Window.h b/headers/os/interface/Window.h index 3d04368950..ac9bfb1563 100644 --- a/headers/os/interface/Window.h +++ b/headers/os/interface/Window.h @@ -347,7 +347,7 @@ private: BList fShortcuts; int32 fTopViewToken; bool fUpdateRequested; - bool _unused3; + bool fOffscreen; bool fIsFilePanel; bool _unused4; bigtime_t fPulseRate; diff --git a/src/kits/app/Application.cpp b/src/kits/app/Application.cpp index cf3b2e785f..61841fe2d3 100644 --- a/src/kits/app/Application.cpp +++ b/src/kits/app/Application.cpp @@ -1478,7 +1478,7 @@ BApplication::_CountWindows(bool includeMenus) const uint32 count = 0; for (int32 i = 0; i < gLooperList.CountLoopers(); i++) { BWindow* window = dynamic_cast(gLooperList.LooperAt(i)); - if (window != NULL && (includeMenus + if (window != NULL && !window->fOffscreen && (includeMenus || dynamic_cast(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(gLooperList.LooperAt(i)); - if (window == NULL || (!includeMenus - && dynamic_cast(window) != NULL)) { + if (window == NULL || window != NULL && window->fOffscreen + || (!includeMenus && dynamic_cast(window) != NULL)) { index++; continue; } diff --git a/src/kits/interface/Bitmap.cpp b/src/kits/interface/Bitmap.cpp index 9d43a42913..3c697af2c7 100644 --- a/src/kits/interface/Bitmap.cpp +++ b/src/kits/interface/Bitmap.cpp @@ -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; } } } diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 2ca20d0173..a3bc3e91c0 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -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(bitmapToken); + fOffscreen = true; } fLink->Attach(fFrame);