Fix various problems found while investigating (and fixing) CID 1453. In short, handling of zombie replicants was completely broken ; they never actually made it to the shelf, and weren't saved/restored either. A problem still remains with respect to restoring them (the shelf relies on the dragged message's drop point to position them, which isn't preserved when the message is flattened/unflattened it seems).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38296 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -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)) {
|
||||
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);
|
||||
if (view) {
|
||||
msg->AddMessage("message", &archive);
|
||||
if (view)
|
||||
pos = view->Frame().LeftTop();
|
||||
} else if (zombie_view)
|
||||
else if (zombie_view)
|
||||
pos = zombie_view->Frame().LeftTop();
|
||||
msg->AddPoint("position", pos);
|
||||
result = B_OK;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1296,20 +1301,21 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
||||
image_id image = -1;
|
||||
BArchivable *archivable = _InstantiateObject(data, &image);
|
||||
|
||||
if (archivable == NULL)
|
||||
return send_reply(data, B_ERROR, uniqueID);
|
||||
BView *view = NULL;
|
||||
|
||||
BView *view = dynamic_cast<BView*>(archivable);
|
||||
if (view == NULL) {
|
||||
printf("Replicant was rejected: it's not a view!");
|
||||
if (archivable) {
|
||||
view = dynamic_cast<BView*>(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)
|
||||
|
||||
@@ -92,6 +92,15 @@ _BZombieReplicantView_::MouseDown(BPoint)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
_BZombieReplicantView_::Archive(BMessage* archive, bool) const
|
||||
{
|
||||
*archive = *fArchive;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_BZombieReplicantView_::SetArchive(BMessage* archive)
|
||||
{
|
||||
|
||||
@@ -38,7 +38,8 @@ const static rgb_color kZombieColor = {220, 220, 220, 255};
|
||||
class _BZombieReplicantView_ : public BBox {
|
||||
|
||||
public:
|
||||
_BZombieReplicantView_(BRect frame, status_t error);
|
||||
_BZombieReplicantView_(BRect frame,
|
||||
status_t error);
|
||||
virtual ~_BZombieReplicantView_();
|
||||
|
||||
virtual void MessageReceived(BMessage*msg);
|
||||
@@ -47,6 +48,9 @@ virtual void Draw(BRect updateRect);
|
||||
|
||||
virtual void MouseDown(BPoint);
|
||||
|
||||
virtual status_t Archive(BMessage* archive,
|
||||
bool deep = true) const;
|
||||
|
||||
void SetArchive(BMessage*);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user