diff --git a/src/kits/interface/Shelf.cpp b/src/kits/interface/Shelf.cpp index afdb8bf905..0af63b5db1 100644 --- a/src/kits/interface/Shelf.cpp +++ b/src/kits/interface/Shelf.cpp @@ -291,19 +291,24 @@ replicant_data::~replicant_data() status_t replicant_data::Archive(BMessage* msg) { - status_t result = B_ERROR; + status_t result = B_OK; BMessage archive; - if (view && (view->Archive(&archive) == B_OK)) { - msg->AddInt32("uniqueid", id); - BPoint pos (0,0); - if (view) { - msg->AddMessage("message", &archive); - pos = view->Frame().LeftTop(); - } else if (zombie_view) - pos = zombie_view->Frame().LeftTop(); - msg->AddPoint("position", pos); - result = B_OK; - } + if (view) + result = view->Archive(&archive); + else if (zombie_view) + result = zombie_view->Archive(&archive); + + if (result != B_OK) + return result; + + msg->AddInt32("uniqueid", id); + BPoint pos (0,0); + msg->AddMessage("message", &archive); + if (view) + pos = view->Frame().LeftTop(); + else if (zombie_view) + pos = zombie_view->Frame().LeftTop(); + msg->AddPoint("position", pos); return result; } @@ -1295,21 +1300,22 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID) // Instantiate the object, if this fails we have a zombie image_id image = -1; BArchivable *archivable = _InstantiateObject(data, &image); - - if (archivable == NULL) - return send_reply(data, B_ERROR, uniqueID); - - BView *view = dynamic_cast(archivable); - if (view == NULL) { - printf("Replicant was rejected: it's not a view!"); - return send_reply(data, B_ERROR, uniqueID); + + BView *view = NULL; + + if (archivable) { + view = dynamic_cast(archivable); + + if (!view) { + return send_reply(data, B_ERROR, uniqueID); + } } - + BDragger* dragger = NULL; BView* replicant = NULL; BDragger::relation relation = BDragger::TARGET_UNKNOWN; _BZombieReplicantView_* zombie = NULL; - if (view != NULL) { + if (view) { const BPoint point = location ? *location : view->Frame().LeftTop(); replicant = _GetReplicant(data, view, point, dragger, relation); if (replicant == NULL) @@ -1444,7 +1450,7 @@ BShelf::_CreateZombie(BMessage *data, BDragger *&dragger) if (data->WasDropped()) { BPoint offset; BPoint dropPoint = data->DropPoint(&offset); - + frame.OffsetTo(fContainerView->ConvertFromScreen(dropPoint) - offset); zombie = new _BZombieReplicantView_(frame, B_ERROR); diff --git a/src/kits/interface/ZombieReplicantView.cpp b/src/kits/interface/ZombieReplicantView.cpp index c9493469bf..e02bfcfaab 100644 --- a/src/kits/interface/ZombieReplicantView.cpp +++ b/src/kits/interface/ZombieReplicantView.cpp @@ -37,12 +37,12 @@ _BZombieReplicantView_::~_BZombieReplicantView_() void -_BZombieReplicantView_::MessageReceived(BMessage *msg) +_BZombieReplicantView_::MessageReceived(BMessage* msg) { switch (msg->what) { case B_ABOUT_REQUESTED: { - const char *addOn = NULL; + const char* addOn = NULL; char error[1024]; if (fArchive->FindString("add_on", &addOn) == B_OK) { char description[B_MIME_TYPE_LENGTH] = ""; @@ -58,7 +58,7 @@ _BZombieReplicantView_::MessageReceived(BMessage *msg) } - BAlert *alert = new (std::nothrow) BAlert("Error", error, "OK", NULL, NULL, + BAlert* alert = new (std::nothrow) BAlert("Error", error, "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); if (alert != NULL) alert->Go(); @@ -92,8 +92,17 @@ _BZombieReplicantView_::MouseDown(BPoint) } +status_t +_BZombieReplicantView_::Archive(BMessage* archive, bool) const +{ + *archive = *fArchive; + + return B_OK; +} + + void -_BZombieReplicantView_::SetArchive(BMessage *archive) +_BZombieReplicantView_::SetArchive(BMessage* archive) { fArchive = archive; } diff --git a/src/kits/interface/ZombieReplicantView.h b/src/kits/interface/ZombieReplicantView.h index 9d1bcd13d9..26a926efbd 100644 --- a/src/kits/interface/ZombieReplicantView.h +++ b/src/kits/interface/ZombieReplicantView.h @@ -38,20 +38,24 @@ const static rgb_color kZombieColor = {220, 220, 220, 255}; class _BZombieReplicantView_ : public BBox { public: - _BZombieReplicantView_(BRect frame, status_t error); -virtual ~_BZombieReplicantView_(); + _BZombieReplicantView_(BRect frame, + status_t error); + virtual ~_BZombieReplicantView_(); -virtual void MessageReceived(BMessage *msg); + virtual void MessageReceived(BMessage*msg); -virtual void Draw(BRect updateRect); + virtual void Draw(BRect updateRect); -virtual void MouseDown(BPoint); + virtual void MouseDown(BPoint); - void SetArchive(BMessage *); + virtual status_t Archive(BMessage* archive, + bool deep = true) const; + + void SetArchive(BMessage*); private: - status_t fError; - BMessage *fArchive; + status_t fError; + BMessage* fArchive; }; #endif /* _ZOMBIE_REPLICANT_VIEW_H */