[haiku-commits] r41178 - haiku/trunk/src/apps/icon-o-matic/document/savers

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 4 Apr 2011 11:21:44 +0200 (CEST)

Author: stippi
Date: 2011-04-04 11:21:43 +0200 (Mon, 04 Apr 2011)
New Revision: 41178
Changeset: https://dev.haiku-os.org/changeset/41178

Modified:
   haiku/trunk/src/apps/icon-o-matic/document/savers/NativeSaver.cpp
   haiku/trunk/src/apps/icon-o-matic/document/savers/NativeSaver.h
Log:
 * 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.


Modified: haiku/trunk/src/apps/icon-o-matic/document/savers/NativeSaver.cpp
===================================================================
--- haiku/trunk/src/apps/icon-o-matic/document/savers/NativeSaver.cpp   
2011-04-04 09:19:48 UTC (rev 41177)
+++ haiku/trunk/src/apps/icon-o-matic/document/savers/NativeSaver.cpp   
2011-04-04 09:21:43 UTC (rev 41178)
@@ -1,34 +1,48 @@
 /*
- * Copyright 2007, Haiku. All rights reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
+ * Copyright 2007, 2011, Stephan Aßmus <superstippi@xxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
  */
+
+
 #include "NativeSaver.h"
 
+#include <stdio.h>
+#include <string.h>
+
 #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;
 }
 

Modified: haiku/trunk/src/apps/icon-o-matic/document/savers/NativeSaver.h
===================================================================
--- haiku/trunk/src/apps/icon-o-matic/document/savers/NativeSaver.h     
2011-04-04 09:19:48 UTC (rev 41177)
+++ haiku/trunk/src/apps/icon-o-matic/document/savers/NativeSaver.h     
2011-04-04 09:21:43 UTC (rev 41178)
@@ -1,17 +1,16 @@
 /*
- * Copyright 2007, Haiku. All rights reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
+ * Copyright 2007, 2011, Stephan Aßmus <superstippi@xxxxxx>.
+ * 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 @@
 
  protected:
                        AttributeSaver          fAttrSaver;
-                       SimpleFileSaver         fFileSaver;
 };
 
+
 #endif // NATIVE_SAVER_H


Other related posts:

  • » [haiku-commits] r41178 - haiku/trunk/src/apps/icon-o-matic/document/savers - superstippi