fixed some Archive() following stippi's path

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17190 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2006-04-21 15:07:09 +00:00
parent 59d1b7be9d
commit 4fdedfbde4
10 changed files with 161 additions and 118 deletions
+14 -8
View File
@@ -222,27 +222,33 @@ BAlert::Instantiate(BMessage* data)
status_t status_t
BAlert::Archive(BMessage* data, bool deep) const BAlert::Archive(BMessage* data, bool deep) const
{ {
BWindow::Archive(data, deep); status_t ret = BWindow::Archive(data, deep);
// Stow the text // Stow the text
data->AddString("_text", fTextView->Text()); if (ret == B_OK)
ret = data->AddString("_text", fTextView->Text());
// Stow the alert type // Stow the alert type
data->AddInt32("_atype", fMsgType); if (ret == B_OK)
ret = data->AddInt32("_atype", fMsgType);
// Stow the button width // Stow the button width
data->AddInt32("_but_width", fButtonWidth); if (ret == B_OK)
ret = data->AddInt32("_but_width", fButtonWidth);
// Stow the shortcut keys // Stow the shortcut keys
if (fKeys[0] || fKeys[1] || fKeys[2]) { if (fKeys[0] || fKeys[1] || fKeys[2]) {
// If we have any to save, we must save something for everyone so it // If we have any to save, we must save something for everyone so it
// doesn't get confusing on the unarchive. // doesn't get confusing on the unarchive.
data->AddInt8("_but_key", fKeys[0]); if (ret == B_OK)
data->AddInt8("_but_key", fKeys[1]); ret = data->AddInt8("_but_key", fKeys[0]);
data->AddInt8("_but_key", fKeys[2]); if (ret == B_OK)
ret = data->AddInt8("_but_key", fKeys[1]);
if (ret == B_OK)
ret = data->AddInt8("_but_key", fKeys[2]);
} }
return B_OK; return ret;
} }
+8 -8
View File
@@ -57,18 +57,18 @@ BBox::Instantiate(BMessage *archive)
status_t status_t
BBox::Archive(BMessage *archive, bool deep) const BBox::Archive(BMessage *archive, bool deep) const
{ {
BView::Archive(archive, deep); status_t ret = BView::Archive(archive, deep);
if (fLabel) if (fLabel && ret == B_OK)
archive->AddString("_label", fLabel); ret = archive->AddString("_label", fLabel);
if (fLabelView) if (fLabelView && ret == B_OK)
archive->AddBool("_lblview", true); ret = archive->AddBool("_lblview", true);
if (fStyle != B_FANCY_BORDER) if (fStyle != B_FANCY_BORDER && ret == B_OK)
archive->AddInt32("_style", fStyle); ret = archive->AddInt32("_style", fStyle);
return B_OK; return ret;
} }
+8 -4
View File
@@ -121,14 +121,18 @@ status_t
BDragger::Archive(BMessage *data, bool deep) const BDragger::Archive(BMessage *data, bool deep) const
{ {
BMessage popupMsg; BMessage popupMsg;
status_t ret = B_OK;
if (fPopUp) { if (fPopUp) {
fPopUp->Archive(&popupMsg); ret = fPopUp->Archive(&popupMsg);
data->AddMessage("_popup", &popupMsg); if (ret == B_OK)
ret = data->AddMessage("_popup", &popupMsg);
} }
data->AddInt32("_rel", fRelation); if (ret == B_OK)
ret = data->AddInt32("_rel", fRelation);
if (ret != B_OK)
return ret;
return BView::Archive(data, deep); return BView::Archive(data, deep);
} }
+12 -10
View File
@@ -132,19 +132,21 @@ BMenuField::Instantiate(BMessage *data)
status_t status_t
BMenuField::Archive(BMessage *data, bool deep) const BMenuField::Archive(BMessage *data, bool deep) const
{ {
BView::Archive(data, deep); status_t ret = BView::Archive(data, deep);
if (Label()) if (ret == B_OK && Label())
data->AddString("_label", Label()); ret = data->AddString("_label", Label());
if (!IsEnabled()) if (ret == B_OK && !IsEnabled())
data->AddBool("_disable", true); ret = data->AddBool("_disable", true);
data->AddInt32("_align", Alignment()); if (ret == B_OK)
data->AddFloat("_divide", Divider()); ret = data->AddInt32("_align", Alignment());
if (ret == B_OK)
ret = data->AddFloat("_divide", Divider());
if (fFixedSizeMB) if (ret == B_OK && fFixedSizeMB)
data->AddBool("be:fixeds", true); ret = data->AddBool("be:fixeds", true);
// BMenuItem *item = fMenuBar->ItemAt(0); // BMenuItem *item = fMenuBar->ItemAt(0);
// if (!item) // if (!item)
@@ -154,7 +156,7 @@ BMenuField::Archive(BMessage *data, bool deep) const
// if (bmcitem && !bmcitem->fShowPopUpMarker) // if (bmcitem && !bmcitem->fShowPopUpMarker)
// data->AddBool("be:dmark", false); // data->AddBool("be:dmark", false);
return B_OK; return ret;
} }
+17 -15
View File
@@ -182,34 +182,36 @@ BMenuItem::Instantiate(BMessage *data)
status_t status_t
BMenuItem::Archive(BMessage *data, bool deep) const BMenuItem::Archive(BMessage *data, bool deep) const
{ {
status_t ret = B_OK;
if (fLabel) if (fLabel)
data->AddString("_label", Label()); ret = data->AddString("_label", Label());
if (!IsEnabled()) if (ret == B_OK && !IsEnabled())
data->AddBool("_disable", true); ret = data->AddBool("_disable", true);
if (IsMarked()) if (ret == B_OK && IsMarked())
data->AddBool("_marked", true); ret = data->AddBool("_marked", true);
if (fUserTrigger) if (ret == B_OK && fUserTrigger)
data->AddInt32("_user_trig", fUserTrigger); ret = data->AddInt32("_user_trig", fUserTrigger);
if (fShortcutChar) { if (ret == B_OK && fShortcutChar) {
data->AddInt32("_shortcut", fShortcutChar); ret = data->AddInt32("_shortcut", fShortcutChar);
data->AddInt32("_mods", fModifiers); if (ret == B_OK)
ret = data->AddInt32("_mods", fModifiers);
} }
if (Message()) if (ret == B_OK && Message())
data->AddMessage("_msg", Message()); ret = data->AddMessage("_msg", Message());
if (deep && fSubmenu) { if (ret == B_OK && deep && fSubmenu) {
BMessage submenu; BMessage submenu;
if (fSubmenu->Archive(&submenu, true) == B_OK) if (fSubmenu->Archive(&submenu, true) == B_OK)
data->AddMessage("_submenu", &submenu); ret = data->AddMessage("_submenu", &submenu);
} }
return B_OK; return ret;
} }
+5 -1
View File
@@ -236,12 +236,16 @@ BPicture::Archive(BMessage *archive, bool deep) const
return err; return err;
err = archive->AddData("_data", B_RAW_TYPE, extent->Data(), extent->Size()); err = archive->AddData("_data", B_RAW_TYPE, extent->Data(), extent->Size());
if (err != B_OK)
return err;
for (int32 i = 0; i < extent->CountPictures(); i++) { for (int32 i = 0; i < extent->CountPictures(); i++) {
BMessage picMsg; BMessage picMsg;
((BPicture*)extent->PictureAt(i))->Archive(&picMsg, deep); ((BPicture*)extent->PictureAt(i))->Archive(&picMsg, deep);
archive->AddMessage("piclib", &picMsg); err = archive->AddMessage("piclib", &picMsg);
if (err != B_OK)
break;
} }
return err; return err;
+23 -9
View File
@@ -223,16 +223,30 @@ BScrollBar::Instantiate(BMessage *data)
status_t status_t
BScrollBar::Archive(BMessage *data, bool deep) const BScrollBar::Archive(BMessage *data, bool deep) const
{ {
BView::Archive(data,deep); status_t err = BView::Archive(data,deep);
data->AddFloat("_range",fMin); if (err != B_OK)
data->AddFloat("_range",fMax); return err;
data->AddFloat("_steps",fSmallStep); err = data->AddFloat("_range",fMin);
data->AddFloat("_steps",fLargeStep); if (err != B_OK)
data->AddFloat("_val",fValue); return err;
data->AddInt32("_orient",(int32)fOrientation); err = data->AddFloat("_range",fMax);
data->AddInt32("_prop",fProportion); if (err != B_OK)
return err;
err = data->AddFloat("_steps",fSmallStep);
if (err != B_OK)
return err;
err = data->AddFloat("_steps",fLargeStep);
if (err != B_OK)
return err;
err = data->AddFloat("_val",fValue);
if (err != B_OK)
return err;
err = data->AddInt32("_orient",(int32)fOrientation);
if (err != B_OK)
return err;
err = data->AddInt32("_prop",fProportion);
return B_OK; return err;
} }
// AttachedToWindow // AttachedToWindow
+15 -12
View File
@@ -176,32 +176,35 @@ BShape::~BShape()
status_t status_t
BShape::Archive(BMessage *archive, bool deep) const BShape::Archive(BMessage *archive, bool deep) const
{ {
status_t error = BArchivable::Archive(archive, deep); status_t err = BArchivable::Archive(archive, deep);
if (error != B_OK) if (err != B_OK)
return error; return err;
shape_data *data = (shape_data*)fPrivateData; shape_data *data = (shape_data*)fPrivateData;
// If no valid shape data, return // If no valid shape data, return
if (data->opCount == 0 || data->ptCount == 0) if (data->opCount == 0 || data->ptCount == 0)
return error; return err;
// Avoids allocation for each point // Avoids allocation for each point
archive->AddData("pts", B_POINT_TYPE, data->ptList, sizeof(BPoint), true, err = archive->AddData("pts", B_POINT_TYPE, data->ptList, sizeof(BPoint), true,
data->ptCount); data->ptCount);
if (err != B_OK)
return err;
for (int32 i = 1; i < data->ptCount; i++) for (int32 i = 1; i < data->ptCount && err == B_OK; i++)
archive->AddPoint("pts", data->ptList[i]); err = archive->AddPoint("pts", data->ptList[i]);
// Avoids allocation for each op // Avoids allocation for each op
archive->AddData("ops", B_INT32_TYPE, data->opList, sizeof(int32), true, if (err == B_OK)
data->opCount); err = archive->AddData("ops", B_INT32_TYPE, data->opList, sizeof(int32), true,
data->opCount);
for (int32 i = 1; i < data->opCount; i++) for (int32 i = 1; i < data->opCount && err == B_OK ; i++)
archive->AddInt32("ops", data->opList[i]); err = archive->AddInt32("ops", data->opList[i]);
return error; return err;
} }
+6 -5
View File
@@ -59,14 +59,15 @@ BStringView::Instantiate(BMessage* data)
status_t status_t
BStringView::Archive(BMessage* data, bool deep) const BStringView::Archive(BMessage* data, bool deep) const
{ {
BView::Archive(data, deep); status_t err = BView::Archive(data, deep);
if (fText) if (err == B_OK && fText)
data->AddString("_text", fText); err = data->AddString("_text", fText);
data->AddInt32("_align", fAlign); if (err == B_OK)
err = data->AddInt32("_align", fAlign);
return B_OK; return err;
} }
+52 -45
View File
@@ -443,96 +443,103 @@ BView::Instantiate(BMessage *data)
status_t status_t
BView::Archive(BMessage *data, bool deep) const BView::Archive(BMessage *data, bool deep) const
{ {
status_t retval = BHandler::Archive(data, deep); status_t ret = BHandler::Archive(data, deep);
if (retval != B_OK) if (ret != B_OK)
return retval; return ret;
if (fState->archiving_flags & B_VIEW_FRAME_BIT) if (fState->archiving_flags & B_VIEW_FRAME_BIT)
data->AddRect("_frame", Bounds().OffsetToCopy(fParentOffset)); ret = data->AddRect("_frame", Bounds().OffsetToCopy(fParentOffset));
if (fState->archiving_flags & B_VIEW_RESIZE_BIT) if (ret == B_OK && fState->archiving_flags & B_VIEW_RESIZE_BIT)
data->AddInt32("_resize_mode", ResizingMode()); ret = data->AddInt32("_resize_mode", ResizingMode());
if (fState->archiving_flags & B_VIEW_FLAGS_BIT) if (ret == B_OK && fState->archiving_flags & B_VIEW_FLAGS_BIT)
data->AddInt32("_flags", Flags()); ret = data->AddInt32("_flags", Flags());
if (fState->archiving_flags & B_VIEW_EVENT_MASK_BIT) { if (ret == B_OK && fState->archiving_flags & B_VIEW_EVENT_MASK_BIT) {
data->AddInt32("_evmask", fEventMask); ret = data->AddInt32("_evmask", fEventMask);
data->AddInt32("_evmask", fEventOptions); if (ret == B_OK)
ret = data->AddInt32("_evmask", fEventOptions);
} }
if (fState->archiving_flags & B_VIEW_FONT_BIT) { if (ret == B_OK && fState->archiving_flags & B_VIEW_FONT_BIT) {
BFont font; BFont font;
GetFont(&font); GetFont(&font);
font_family family; font_family family;
font_style style; font_style style;
font.GetFamilyAndStyle(&family, &style); font.GetFamilyAndStyle(&family, &style);
data->AddString("_fname", family); ret = data->AddString("_fname", family);
data->AddString("_fname", style); if (ret == B_OK)
ret = data->AddString("_fname", style);
data->AddFloat("_fflt", font.Size()); if (ret == B_OK)
data->AddFloat("_fflt", font.Shear()); ret = data->AddFloat("_fflt", font.Size());
data->AddFloat("_fflt", font.Rotation()); if (ret == B_OK)
ret = data->AddFloat("_fflt", font.Shear());
if (ret == B_OK)
ret = data->AddFloat("_fflt", font.Rotation());
} }
// colors // colors
if (fState->archiving_flags & B_VIEW_HIGH_COLOR_BIT) if (ret == B_OK && fState->archiving_flags & B_VIEW_HIGH_COLOR_BIT)
data->AddInt32("_color", get_uint32_color(HighColor())); ret = data->AddInt32("_color", get_uint32_color(HighColor()));
if (fState->archiving_flags & B_VIEW_LOW_COLOR_BIT) if (ret == B_OK && fState->archiving_flags & B_VIEW_LOW_COLOR_BIT)
data->AddInt32("_color", get_uint32_color(LowColor())); ret = data->AddInt32("_color", get_uint32_color(LowColor()));
if (fState->archiving_flags & B_VIEW_VIEW_COLOR_BIT) if (ret == B_OK && fState->archiving_flags & B_VIEW_VIEW_COLOR_BIT)
data->AddInt32("_color", get_uint32_color(ViewColor())); ret = data->AddInt32("_color", get_uint32_color(ViewColor()));
// NOTE: we do not use this flag any more // NOTE: we do not use this flag any more
// if ( 1 ){ // if ( 1 ){
// data->AddInt32("_dbuf", 1); // ret = data->AddInt32("_dbuf", 1);
// } // }
if (fState->archiving_flags & B_VIEW_ORIGIN_BIT) if (ret == B_OK && fState->archiving_flags & B_VIEW_ORIGIN_BIT)
data->AddPoint("_origin", Origin()); ret = data->AddPoint("_origin", Origin());
if (fState->archiving_flags & B_VIEW_PEN_SIZE_BIT) if (ret == B_OK && fState->archiving_flags & B_VIEW_PEN_SIZE_BIT)
data->AddFloat("_psize", PenSize()); ret = data->AddFloat("_psize", PenSize());
if (fState->archiving_flags & B_VIEW_PEN_LOCATION_BIT) if (ret == B_OK && fState->archiving_flags & B_VIEW_PEN_LOCATION_BIT)
data->AddPoint("_ploc", PenLocation()); ret = data->AddPoint("_ploc", PenLocation());
if (fState->archiving_flags & B_VIEW_LINE_MODES_BIT) { if (ret == B_OK && fState->archiving_flags & B_VIEW_LINE_MODES_BIT) {
data->AddInt16("_lmcapjoin", (int16)LineCapMode()); ret = data->AddInt16("_lmcapjoin", (int16)LineCapMode());
data->AddInt16("_lmcapjoin", (int16)LineJoinMode()); if (ret == B_OK)
data->AddFloat("_lmmiter", LineMiterLimit()); ret = data->AddInt16("_lmcapjoin", (int16)LineJoinMode());
if (ret == B_OK)
ret = data->AddFloat("_lmmiter", LineMiterLimit());
} }
if (fState->archiving_flags & B_VIEW_BLENDING_BIT) { if (ret == B_OK && fState->archiving_flags & B_VIEW_BLENDING_BIT) {
source_alpha alphaSourceMode; source_alpha alphaSourceMode;
alpha_function alphaFunctionMode; alpha_function alphaFunctionMode;
GetBlendingMode(&alphaSourceMode, &alphaFunctionMode); GetBlendingMode(&alphaSourceMode, &alphaFunctionMode);
data->AddInt16("_blend", (int16)alphaSourceMode); ret = data->AddInt16("_blend", (int16)alphaSourceMode);
data->AddInt16("_blend", (int16)alphaFunctionMode); if (ret == B_OK)
ret = data->AddInt16("_blend", (int16)alphaFunctionMode);
} }
if (fState->archiving_flags & B_VIEW_DRAWING_MODE_BIT) if (ret == B_OK && fState->archiving_flags & B_VIEW_DRAWING_MODE_BIT)
data->AddInt32("_dmod", DrawingMode()); ret = data->AddInt32("_dmod", DrawingMode());
if (deep) { if (deep) {
int32 i = 0; int32 i = 0;
BView *child; BView *child;
while ((child = ChildAt(i++)) != NULL) { while (ret == B_OK && (child = ChildAt(i++)) != NULL) {
BMessage childArchive; BMessage childArchive;
retval = child->Archive(&childArchive, deep); ret = child->Archive(&childArchive, deep);
if (retval == B_OK) if (ret == B_OK)
data->AddMessage("_views", &childArchive); ret = data->AddMessage("_views", &childArchive);
} }
} }
return retval; return ret;
} }