BShelf: Fix crash in the case that view is NULL.
Also correct some formatting. Fixes #12584.
This commit is contained in:
@@ -294,11 +294,11 @@ replicant_data::Archive(BMessage* msg)
|
|||||||
{
|
{
|
||||||
status_t result = B_OK;
|
status_t result = B_OK;
|
||||||
BMessage archive;
|
BMessage archive;
|
||||||
if (view)
|
if (view)
|
||||||
result = view->Archive(&archive);
|
result = view->Archive(&archive);
|
||||||
else if (zombie_view)
|
else if (zombie_view)
|
||||||
result = zombie_view->Archive(&archive);
|
result = zombie_view->Archive(&archive);
|
||||||
|
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
@@ -307,7 +307,7 @@ replicant_data::Archive(BMessage* msg)
|
|||||||
msg->AddMessage("message", &archive);
|
msg->AddMessage("message", &archive);
|
||||||
if (view)
|
if (view)
|
||||||
pos = view->Frame().LeftTop();
|
pos = view->Frame().LeftTop();
|
||||||
else if (zombie_view)
|
else if (zombie_view)
|
||||||
pos = zombie_view->Frame().LeftTop();
|
pos = zombie_view->Frame().LeftTop();
|
||||||
msg->AddPoint("position", pos);
|
msg->AddPoint("position", pos);
|
||||||
|
|
||||||
@@ -1298,16 +1298,16 @@ 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);
|
||||||
|
|
||||||
BView *view = NULL;
|
BView *view = NULL;
|
||||||
|
|
||||||
if (archivable != NULL) {
|
if (archivable != NULL) {
|
||||||
view = dynamic_cast<BView*>(archivable);
|
view = dynamic_cast<BView*>(archivable);
|
||||||
|
|
||||||
if (view == NULL)
|
if (view == NULL)
|
||||||
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;
|
||||||
@@ -1448,7 +1448,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);
|
||||||
@@ -1498,14 +1498,15 @@ BShelf::_GetProperty(BMessage *msg, BMessage *reply)
|
|||||||
for (int32 i = 0; i < CountReplicants(); i++) {
|
for (int32 i = 0; i < CountReplicants(); i++) {
|
||||||
BView *view = NULL;
|
BView *view = NULL;
|
||||||
ReplicantAt(i, &view, &ID, &err);
|
ReplicantAt(i, &view, &ID, &err);
|
||||||
if (err == B_OK) {
|
if (err != B_OK || view == NULL)
|
||||||
if (view->Name() != NULL &&
|
continue;
|
||||||
strlen(view->Name()) == strlen(name) && !strcmp(view->Name(), name)) {
|
if (view->Name() != NULL &&
|
||||||
replicant = view;
|
strlen(view->Name()) == strlen(name) &&
|
||||||
break;
|
!strcmp(view->Name(), name)) {
|
||||||
}
|
replicant = view;
|
||||||
err = B_NAME_NOT_FOUND;
|
break;
|
||||||
}
|
}
|
||||||
|
err = B_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1516,13 +1517,13 @@ BShelf::_GetProperty(BMessage *msg, BMessage *reply)
|
|||||||
for (int32 i = 0; i < CountReplicants(); i++) {
|
for (int32 i = 0; i < CountReplicants(); i++) {
|
||||||
BView *view = NULL;
|
BView *view = NULL;
|
||||||
ReplicantAt(i, &view, &ID, &err);
|
ReplicantAt(i, &view, &ID, &err);
|
||||||
if (err == B_OK) {
|
if (err != B_OK || view == NULL)
|
||||||
if (ID == id) {
|
continue;
|
||||||
replicant = view;
|
if (ID == id) {
|
||||||
break;
|
replicant = view;
|
||||||
}
|
break;
|
||||||
err = B_NAME_NOT_FOUND;
|
|
||||||
}
|
}
|
||||||
|
err = B_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user