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)) {
|
||||
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<BView*>(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<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)
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user