Added a wrapper method to instantiate_object(), where we catch any
possible exception thrown from the constructor called by the function itself, for safety. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21750 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -100,6 +100,8 @@ class BShelf : public BHandler {
|
|||||||
BPoint* location, uint32 uniqueID);
|
BPoint* location, uint32 uniqueID);
|
||||||
status_t _GetProperty(BMessage* message, BMessage* reply);
|
status_t _GetProperty(BMessage* message, BMessage* reply);
|
||||||
|
|
||||||
|
static BArchivable* _InstantiateObject(BMessage *archive, image_id *image);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BView* fContainerView;
|
BView* fContainerView;
|
||||||
BDataIO* fStream;
|
BDataIO* fStream;
|
||||||
|
|||||||
@@ -1140,7 +1140,7 @@ 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;
|
image_id image;
|
||||||
BArchivable *archivable = instantiate_object(data, &image);
|
BArchivable *archivable = _InstantiateObject(data, &image);
|
||||||
if (archivable) {
|
if (archivable) {
|
||||||
BView *view = dynamic_cast<BView*>(archivable);
|
BView *view = dynamic_cast<BView*>(archivable);
|
||||||
BPoint point;
|
BPoint point;
|
||||||
@@ -1157,7 +1157,7 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
|||||||
if (data->FindMessage("__widget", &widget) == B_OK) {
|
if (data->FindMessage("__widget", &widget) == B_OK) {
|
||||||
image_id draggerImage = B_ERROR;
|
image_id draggerImage = B_ERROR;
|
||||||
replicant = view;
|
replicant = view;
|
||||||
dragger = dynamic_cast<BDragger*>(instantiate_object(&widget, &draggerImage));
|
dragger = dynamic_cast<BDragger*>(_InstantiateObject(&widget, &draggerImage));
|
||||||
if (dragger != NULL) {
|
if (dragger != NULL) {
|
||||||
// Replicant is either a sibling or unknown
|
// Replicant is either a sibling or unknown
|
||||||
dragger->_SetViewToDrag(replicant);
|
dragger->_SetViewToDrag(replicant);
|
||||||
@@ -1325,3 +1325,19 @@ BShelf::_GetProperty(BMessage *msg, BMessage *reply)
|
|||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
BArchivable *
|
||||||
|
BShelf::_InstantiateObject(BMessage *archive, image_id *image)
|
||||||
|
{
|
||||||
|
// Stay on the safe side. The constructor called by instantiate_object
|
||||||
|
// could throw an exception, which we catch here. Otherwise our calling app
|
||||||
|
// could die without notice.
|
||||||
|
try {
|
||||||
|
return instantiate_object(archive, image);
|
||||||
|
} catch (...) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user