diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 703ac7e502..e09db8996b 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -2675,7 +2675,7 @@ ServerApp::CreatePicture(const ServerPicture *original) ServerPicture * ServerApp::FindPicture(const int32 &token) const { - // TODO: we need to make sure the picture is ours?! + // TODO: we need to make sure the picture is ours?! ServerPicture* picture; if (gTokenSpace.GetToken(token, kPictureToken, (void**)&picture) == B_OK) return picture; diff --git a/src/servers/app/ServerPicture.cpp b/src/servers/app/ServerPicture.cpp index 786c56cbda..722f5bf5fd 100644 --- a/src/servers/app/ServerPicture.cpp +++ b/src/servers/app/ServerPicture.cpp @@ -777,7 +777,12 @@ ServerPicture::~ServerPicture() { delete fData; gTokenSpace.RemoveToken(fToken); - delete fPictures; + + if (fPictures != NULL) { + for (int32 i = fPictures->CountItems() - 1; i >= 0; i--) + delete static_cast(fPictures->ItemAtFast(i)); + delete fPictures; + } } diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 71961effb8..a1cfe4893f 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -2674,7 +2674,15 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link) if (link.Read(&token) == B_OK) { BPoint where; link.Read(&where); - picture->WriteDrawPicture(where, token); + + ServerPicture *pictureToDraw = App()->FindPicture(token); + if (picture != NULL) { + // We need to make a copy of the picture, since it can change + // after it has been drawn + ServerPicture *copy = App()->CreatePicture(pictureToDraw); + picture->NestPicture(copy); + picture->WriteDrawPicture(where, copy->Token()); + } } break; } @@ -2695,7 +2703,6 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver &link) if (!steppedDown) return false; - steppedDown->NestPicture(picture); fCurrentLayer->SetPicture(steppedDown); fLink.StartMessage(B_OK); fLink.Attach(picture->Token());