* 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 fIsZombie;
char fErrCount;
bool fPopUpIsCustom;
BBitmap * fBitmap;
BPopUpMenu* fPopUp;
uint32 _reserved[3];

View File

@ -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<BPopUpMenu *>(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;
}