People: allocate BFile on stack
This commit is contained in:
@@ -292,11 +292,9 @@ PersonView::IsSaved() const
|
|||||||
void
|
void
|
||||||
PersonView::Save()
|
PersonView::Save()
|
||||||
{
|
{
|
||||||
BFile* file = new(std::nothrow) BFile(fRef, B_READ_WRITE);
|
BFile file(fRef, B_READ_WRITE);
|
||||||
if (file == NULL || file->InitCheck() != B_NO_ERROR) {
|
if (file.InitCheck() != B_NO_ERROR)
|
||||||
delete file;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
fSaving = true;
|
fSaving = true;
|
||||||
|
|
||||||
@@ -304,7 +302,7 @@ PersonView::Save()
|
|||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++) {
|
||||||
AttributeTextControl* control = fControls.ItemAt(i);
|
AttributeTextControl* control = fControls.ItemAt(i);
|
||||||
const char* value = control->Text();
|
const char* value = control->Text();
|
||||||
file->WriteAttr(control->Attribute().String(), B_STRING_TYPE, 0,
|
file.WriteAttr(control->Attribute().String(), B_STRING_TYPE, 0,
|
||||||
value, strlen(value) + 1);
|
value, strlen(value) + 1);
|
||||||
control->Update();
|
control->Update();
|
||||||
}
|
}
|
||||||
@@ -312,8 +310,8 @@ PersonView::Save()
|
|||||||
// Write the picture, if any, in the person file content
|
// Write the picture, if any, in the person file content
|
||||||
if (fPictureView) {
|
if (fPictureView) {
|
||||||
// Trim any previous content
|
// Trim any previous content
|
||||||
file->Seek(0, SEEK_SET);
|
file.Seek(0, SEEK_SET);
|
||||||
file->SetSize(0);
|
file.SetSize(0);
|
||||||
|
|
||||||
BBitmap* picture = fPictureView->Bitmap();
|
BBitmap* picture = fPictureView->Bitmap();
|
||||||
if (picture) {
|
if (picture) {
|
||||||
@@ -323,7 +321,7 @@ PersonView::Save()
|
|||||||
stream.DetachBitmap(&picture);
|
stream.DetachBitmap(&picture);
|
||||||
|
|
||||||
BTranslatorRoster* roster = BTranslatorRoster::Default();
|
BTranslatorRoster* roster = BTranslatorRoster::Default();
|
||||||
roster->Translate(&stream, NULL, NULL, file,
|
roster->Translate(&stream, NULL, NULL, &file,
|
||||||
fPictureView->SuggestedType(), B_TRANSLATOR_BITMAP,
|
fPictureView->SuggestedType(), B_TRANSLATOR_BITMAP,
|
||||||
fPictureView->SuggestedMIMEType());
|
fPictureView->SuggestedMIMEType());
|
||||||
|
|
||||||
@@ -332,10 +330,9 @@ PersonView::Save()
|
|||||||
fPictureView->Update();
|
fPictureView->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
file->GetModificationTime(&fLastModificationTime);
|
file.GetModificationTime(&fLastModificationTime);
|
||||||
|
|
||||||
fSaving = false;
|
fSaving = false;
|
||||||
delete file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user