From df1b8782c7bde3bbf1d3cb77f8a7ad135bad178a Mon Sep 17 00:00:00 2001 From: ejakowatz Date: Tue, 3 Jun 2003 04:38:17 +0000 Subject: [PATCH] Fixes for bugs in BFlattenable convenience functions (revealed by the new unit tests). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3404 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/app/Message.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/kits/app/Message.cpp b/src/kits/app/Message.cpp index 1b8e2f17eb..a98a169ee8 100644 --- a/src/kits/app/Message.cpp +++ b/src/kits/app/Message.cpp @@ -787,8 +787,12 @@ status_t BMessage::AddFlat(const char* name, BFlattenable* obj, int32 count) char* buffer = new(nothrow) char[size]; if (buffer) { - err = AddData(name, obj->TypeCode(), (void*)buffer, size, - obj->IsFixedSize(), count); + err = obj->Flatten((void*)buffer, size); + if (!err) + { + err = AddData(name, obj->TypeCode(), (void*)buffer, size, + obj->IsFixedSize(), count); + } delete[] buffer; } else @@ -1147,7 +1151,11 @@ status_t BMessage::ReplaceFlat(const char* name, int32 index, BFlattenable* obj) char* buffer = new(nothrow) char[size]; if (buffer) { - err = ReplaceData(name, obj->TypeCode(), index, (void*)buffer, size); + err = obj->Flatten(buffer, size); + if (!err) + { + err = ReplaceData(name, obj->TypeCode(), index, (void*)buffer, size); + } delete[] buffer; }