* 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
This commit is contained in:
Alexandre Deckner 2009-04-05 19:59:53 +00:00
parent e18d4a2d06
commit 9cfb11a5cf
2 changed files with 14 additions and 8 deletions

View File

@ -114,6 +114,7 @@ class BDragger : public BView {
bool fTransition; bool fTransition;
bool fIsZombie; bool fIsZombie;
char fErrCount; char fErrCount;
bool fPopUpIsCustom;
BBitmap * fBitmap; BBitmap * fBitmap;
BPopUpMenu* fPopUp; BPopUpMenu* fPopUp;
uint32 _reserved[3]; uint32 _reserved[3];

View File

@ -59,6 +59,7 @@ BDragger::BDragger(BRect bounds, BView *target, uint32 rmask, uint32 flags)
fTransition(false), fTransition(false),
fIsZombie(false), fIsZombie(false),
fErrCount(0), fErrCount(0),
fPopUpIsCustom(false),
fPopUp(NULL) fPopUp(NULL)
{ {
fBitmap = new BBitmap(BRect(0.0f, 0.0f, 7.0f, 7.0f), B_CMAP8, false, false); 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), fTransition(false),
fIsZombie(false), fIsZombie(false),
fErrCount(0), fErrCount(0),
fPopUpIsCustom(false),
fPopUp(NULL) fPopUp(NULL)
{ {
data->FindInt32("_rel", (int32 *)&fRelation); data->FindInt32("_rel", (int32 *)&fRelation);
@ -85,16 +87,17 @@ BDragger::BDragger(BMessage *data)
if (data->FindMessage("_popup", &popupMsg) == B_OK) { if (data->FindMessage("_popup", &popupMsg) == B_OK) {
BArchivable *archivable = instantiate_object(&popupMsg); BArchivable *archivable = instantiate_object(&popupMsg);
if (archivable) if (archivable) {
fPopUp = dynamic_cast<BPopUpMenu *>(archivable); fPopUp = dynamic_cast<BPopUpMenu *>(archivable);
fPopUpIsCustom = true;
}
} }
} }
BDragger::~BDragger() BDragger::~BDragger()
{ {
SetPopUp(NULL); delete fPopUp;
delete fBitmap; delete fBitmap;
} }
@ -117,7 +120,7 @@ BDragger::Archive(BMessage *data, bool deep) const
BMessage popupMsg; BMessage popupMsg;
if (fPopUp) { if (fPopUp && fPopUpIsCustom) {
bool windowLocked = fPopUp->Window()->Lock(); bool windowLocked = fPopUp->Window()->Lock();
ret = fPopUp->Archive(&popupMsg, deep); ret = fPopUp->Archive(&popupMsg, deep);
@ -510,12 +513,14 @@ BDragger::AllDetached()
status_t status_t
BDragger::SetPopUp(BPopUpMenu *menu) BDragger::SetPopUp(BPopUpMenu *menu)
{ {
if (fPopUp != menu) if (menu != NULL && menu != fPopUp) {
delete fPopUp; delete fPopUp;
fPopUp = menu; fPopUp = menu;
fPopUpIsCustom = true;
return B_OK; return B_OK;
} }
return B_ERROR;
}
BPopUpMenu * BPopUpMenu *