From e62d9c79e12d31c5f47ff0129595a421a5599ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 4 Apr 2011 09:21:43 +0000 Subject: [PATCH] * Inherit from SimpleFileSaver, which enables the logic in the application to set the file panel save text to the previous ref name. * Wait for the export thread to finish writing the file before trying to set the icon attribute. Usually it never worked when saving a file for the first time, since the file did not yet exist. * Report errors to std::err. * Code style cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41178 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../document/savers/NativeSaver.cpp | 40 +++++++++++++------ .../document/savers/NativeSaver.h | 13 +++--- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/apps/icon-o-matic/document/savers/NativeSaver.cpp b/src/apps/icon-o-matic/document/savers/NativeSaver.cpp index 8fdce21130..fff193fd1e 100644 --- a/src/apps/icon-o-matic/document/savers/NativeSaver.cpp +++ b/src/apps/icon-o-matic/document/savers/NativeSaver.cpp @@ -1,34 +1,48 @@ /* - * Copyright 2007, Haiku. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Stephan Aßmus + * Copyright 2007, 2011, Stephan Aßmus . + * All rights reserved. Distributed under the terms of the MIT License. */ + + #include "NativeSaver.h" +#include +#include + #include "FlatIconFormat.h" #include "MessageExporter.h" -// constructor + NativeSaver::NativeSaver(const entry_ref& ref) - : fAttrSaver(ref, kVectorAttrNodeName), - fFileSaver(new MessageExporter(), ref) + : + SimpleFileSaver(new MessageExporter(), ref), + fAttrSaver(ref, kVectorAttrNodeName) { } -// destructor + NativeSaver::~NativeSaver() { } -// Save + status_t NativeSaver::Save(Document* document) { - status_t ret = fFileSaver.Save(document); - if (ret < B_OK) + status_t ret = SimpleFileSaver::Save(document); + if (ret != B_OK) { + fprintf(stderr, "Error saving icon: %s\n", strerror(ret)); return ret; - return fAttrSaver.Save(document); + } + + WaitForExportThread(); + + ret = fAttrSaver.Save(document); + if (ret != B_OK) { + fprintf(stderr, "Error saving icon attribute: %s\n", strerror(ret)); + return ret; + } + + return B_OK; } diff --git a/src/apps/icon-o-matic/document/savers/NativeSaver.h b/src/apps/icon-o-matic/document/savers/NativeSaver.h index c7a21db7ad..0a2e1eef4e 100644 --- a/src/apps/icon-o-matic/document/savers/NativeSaver.h +++ b/src/apps/icon-o-matic/document/savers/NativeSaver.h @@ -1,17 +1,16 @@ /* - * Copyright 2007, Haiku. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Stephan Aßmus + * Copyright 2007, 2011, Stephan Aßmus . + * All rights reserved. Distributed under the terms of the MIT License. */ #ifndef NATIVE_SAVER_H #define NATIVE_SAVER_H + #include "AttributeSaver.h" #include "SimpleFileSaver.h" -class NativeSaver : public DocumentSaver { + +class NativeSaver : public SimpleFileSaver { public: NativeSaver(const entry_ref& ref); virtual ~NativeSaver(); @@ -20,7 +19,7 @@ class NativeSaver : public DocumentSaver { protected: AttributeSaver fAttrSaver; - SimpleFileSaver fFileSaver; }; + #endif // NATIVE_SAVER_H