From 9cfb11a5cfdc1deb08aecb972ed9b38b7fe9c6cb Mon Sep 17 00:00:00 2001 From: Alexandre Deckner Date: Sun, 5 Apr 2009 19:59:53 +0000 Subject: [PATCH] * Make BDragger respect the doc and only archive/unarchive the popup menu when it's a custom provided one. Incidentally makes #1775 (that i'll reopen in a moment, see r29947) a lot less likely to happen for most users since it can now only happen with those customized popups. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29949 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/Dragger.h | 1 + src/kits/interface/Dragger.cpp | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/headers/os/interface/Dragger.h b/headers/os/interface/Dragger.h index 981c278476..55aa70c672 100644 --- a/headers/os/interface/Dragger.h +++ b/headers/os/interface/Dragger.h @@ -114,6 +114,7 @@ class BDragger : public BView { bool fTransition; bool fIsZombie; char fErrCount; + bool fPopUpIsCustom; BBitmap * fBitmap; BPopUpMenu* fPopUp; uint32 _reserved[3]; diff --git a/src/kits/interface/Dragger.cpp b/src/kits/interface/Dragger.cpp index 6e4b476ca2..3182e962da 100644 --- a/src/kits/interface/Dragger.cpp +++ b/src/kits/interface/Dragger.cpp @@ -59,6 +59,7 @@ BDragger::BDragger(BRect bounds, BView *target, uint32 rmask, uint32 flags) fTransition(false), fIsZombie(false), fErrCount(0), + fPopUpIsCustom(false), fPopUp(NULL) { fBitmap = new BBitmap(BRect(0.0f, 0.0f, 7.0f, 7.0f), B_CMAP8, false, false); @@ -74,6 +75,7 @@ BDragger::BDragger(BMessage *data) fTransition(false), fIsZombie(false), fErrCount(0), + fPopUpIsCustom(false), fPopUp(NULL) { data->FindInt32("_rel", (int32 *)&fRelation); @@ -85,16 +87,17 @@ BDragger::BDragger(BMessage *data) if (data->FindMessage("_popup", &popupMsg) == B_OK) { BArchivable *archivable = instantiate_object(&popupMsg); - if (archivable) + if (archivable) { fPopUp = dynamic_cast(archivable); + fPopUpIsCustom = true; + } } } BDragger::~BDragger() { - SetPopUp(NULL); - + delete fPopUp; delete fBitmap; } @@ -117,7 +120,7 @@ BDragger::Archive(BMessage *data, bool deep) const BMessage popupMsg; - if (fPopUp) { + if (fPopUp && fPopUpIsCustom) { bool windowLocked = fPopUp->Window()->Lock(); ret = fPopUp->Archive(&popupMsg, deep); @@ -510,11 +513,13 @@ BDragger::AllDetached() status_t BDragger::SetPopUp(BPopUpMenu *menu) { - if (fPopUp != menu) + if (menu != NULL && menu != fPopUp) { delete fPopUp; - - fPopUp = menu; - return B_OK; + fPopUp = menu; + fPopUpIsCustom = true; + return B_OK; + } + return B_ERROR; }