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
|
status_t
|
||||||
replicant_data::Archive(BMessage* msg)
|
replicant_data::Archive(BMessage* msg)
|
||||||
{
|
{
|
||||||
status_t result = B_ERROR;
|
status_t result = B_OK;
|
||||||
BMessage archive;
|
BMessage archive;
|
||||||
if (view && (view->Archive(&archive) == B_OK)) {
|
if (view)
|
||||||
msg->AddInt32("uniqueid", id);
|
result = view->Archive(&archive);
|
||||||
BPoint pos (0,0);
|
else if (zombie_view)
|
||||||
if (view) {
|
result = zombie_view->Archive(&archive);
|
||||||
msg->AddMessage("message", &archive);
|
|
||||||
pos = view->Frame().LeftTop();
|
if (result != B_OK)
|
||||||
} else if (zombie_view)
|
return result;
|
||||||
pos = zombie_view->Frame().LeftTop();
|
|
||||||
msg->AddPoint("position", pos);
|
msg->AddInt32("uniqueid", id);
|
||||||
result = B_OK;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1295,21 +1300,22 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
|||||||
// Instantiate the object, if this fails we have a zombie
|
// Instantiate the object, if this fails we have a zombie
|
||||||
image_id image = -1;
|
image_id image = -1;
|
||||||
BArchivable *archivable = _InstantiateObject(data, &image);
|
BArchivable *archivable = _InstantiateObject(data, &image);
|
||||||
|
|
||||||
if (archivable == NULL)
|
BView *view = NULL;
|
||||||
return send_reply(data, B_ERROR, uniqueID);
|
|
||||||
|
if (archivable) {
|
||||||
BView *view = dynamic_cast<BView*>(archivable);
|
view = dynamic_cast<BView*>(archivable);
|
||||||
if (view == NULL) {
|
|
||||||
printf("Replicant was rejected: it's not a view!");
|
if (!view) {
|
||||||
return send_reply(data, B_ERROR, uniqueID);
|
return send_reply(data, B_ERROR, uniqueID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BDragger* dragger = NULL;
|
BDragger* dragger = NULL;
|
||||||
BView* replicant = NULL;
|
BView* replicant = NULL;
|
||||||
BDragger::relation relation = BDragger::TARGET_UNKNOWN;
|
BDragger::relation relation = BDragger::TARGET_UNKNOWN;
|
||||||
_BZombieReplicantView_* zombie = NULL;
|
_BZombieReplicantView_* zombie = NULL;
|
||||||
if (view != NULL) {
|
if (view) {
|
||||||
const BPoint point = location ? *location : view->Frame().LeftTop();
|
const BPoint point = location ? *location : view->Frame().LeftTop();
|
||||||
replicant = _GetReplicant(data, view, point, dragger, relation);
|
replicant = _GetReplicant(data, view, point, dragger, relation);
|
||||||
if (replicant == NULL)
|
if (replicant == NULL)
|
||||||
@@ -1444,7 +1450,7 @@ BShelf::_CreateZombie(BMessage *data, BDragger *&dragger)
|
|||||||
if (data->WasDropped()) {
|
if (data->WasDropped()) {
|
||||||
BPoint offset;
|
BPoint offset;
|
||||||
BPoint dropPoint = data->DropPoint(&offset);
|
BPoint dropPoint = data->DropPoint(&offset);
|
||||||
|
|
||||||
frame.OffsetTo(fContainerView->ConvertFromScreen(dropPoint) - offset);
|
frame.OffsetTo(fContainerView->ConvertFromScreen(dropPoint) - offset);
|
||||||
|
|
||||||
zombie = new _BZombieReplicantView_(frame, B_ERROR);
|
zombie = new _BZombieReplicantView_(frame, B_ERROR);
|
||||||
|
|||||||
@@ -37,12 +37,12 @@ _BZombieReplicantView_::~_BZombieReplicantView_()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BZombieReplicantView_::MessageReceived(BMessage *msg)
|
_BZombieReplicantView_::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case B_ABOUT_REQUESTED:
|
case B_ABOUT_REQUESTED:
|
||||||
{
|
{
|
||||||
const char *addOn = NULL;
|
const char* addOn = NULL;
|
||||||
char error[1024];
|
char error[1024];
|
||||||
if (fArchive->FindString("add_on", &addOn) == B_OK) {
|
if (fArchive->FindString("add_on", &addOn) == B_OK) {
|
||||||
char description[B_MIME_TYPE_LENGTH] = "";
|
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);
|
B_WIDTH_AS_USUAL, B_STOP_ALERT);
|
||||||
if (alert != NULL)
|
if (alert != NULL)
|
||||||
alert->Go();
|
alert->Go();
|
||||||
@@ -92,8 +92,17 @@ _BZombieReplicantView_::MouseDown(BPoint)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
_BZombieReplicantView_::Archive(BMessage* archive, bool) const
|
||||||
|
{
|
||||||
|
*archive = *fArchive;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BZombieReplicantView_::SetArchive(BMessage *archive)
|
_BZombieReplicantView_::SetArchive(BMessage* archive)
|
||||||
{
|
{
|
||||||
fArchive = archive;
|
fArchive = archive;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,20 +38,24 @@ const static rgb_color kZombieColor = {220, 220, 220, 255};
|
|||||||
class _BZombieReplicantView_ : public BBox {
|
class _BZombieReplicantView_ : public BBox {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
_BZombieReplicantView_(BRect frame, status_t error);
|
_BZombieReplicantView_(BRect frame,
|
||||||
virtual ~_BZombieReplicantView_();
|
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:
|
private:
|
||||||
status_t fError;
|
status_t fError;
|
||||||
BMessage *fArchive;
|
BMessage* fArchive;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _ZOMBIE_REPLICANT_VIEW_H */
|
#endif /* _ZOMBIE_REPLICANT_VIEW_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user