[haiku-commits] r41176 - haiku/trunk/src/apps/icon-o-matic/import_export

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

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

Modified:
   haiku/trunk/src/apps/icon-o-matic/import_export/Exporter.cpp
   haiku/trunk/src/apps/icon-o-matic/import_export/Exporter.h
Log:
 * Don't return the export thread id as error code in Export().
 * Added WaitForExportThread() method.


Modified: haiku/trunk/src/apps/icon-o-matic/import_export/Exporter.cpp
===================================================================
--- haiku/trunk/src/apps/icon-o-matic/import_export/Exporter.cpp        
2011-04-04 02:21:31 UTC (rev 41175)
+++ haiku/trunk/src/apps/icon-o-matic/import_export/Exporter.cpp        
2011-04-04 09:18:27 UTC (rev 41176)
@@ -1,11 +1,9 @@
 /*
- * Copyright 2006, Haiku. All rights reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
+ * Copyright 2006, 2011, Stephan Aßmus <superstippi@xxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
  */
 
+
 #include "Exporter.h"
 
 #include <fs_attr.h>
@@ -33,7 +31,7 @@
 
 using std::nothrow;
 
-// constructor
+
 Exporter::Exporter()
        : fDocument(NULL),
          fClonedIcon(NULL),
@@ -43,18 +41,15 @@
 {
 }
 
-// destructor
+
 Exporter::~Exporter()
 {
-       if (fExportThread >= 0 && find_thread(NULL) != fExportThread) {
-               status_t ret;
-               wait_for_thread(fExportThread, &ret);
-       }
+       WaitForExportThread();
 
        delete fClonedIcon;
 }
 
-// Export
+
 status_t
 Exporter::Export(Document* document, const entry_ref& ref)
 {
@@ -70,22 +65,36 @@
 
        fExportThread = spawn_thread(_ExportThreadEntry, "export",
                                                                 
B_NORMAL_PRIORITY, this);
-       if (fExportThread >= B_OK)
-               resume_thread(fExportThread);
+       if (fExportThread < 0)
+               return (status_t)fExportThread;
 
-       return fExportThread;
+       resume_thread(fExportThread);
+
+       return B_OK;
 }
 
-// SetSelfDestroy
+
 void
 Exporter::SetSelfDestroy(bool selfDestroy)
 {
        fSelfDestroy = selfDestroy;
 }
 
+
+void
+Exporter::WaitForExportThread()
+{
+       if (fExportThread >= 0 && find_thread(NULL) != fExportThread) {
+               status_t ret;
+               wait_for_thread(fExportThread, &ret);
+               fExportThread = -1;
+       }
+}
+
+
 // #pragma mark -
 
-// _ExportThreadEntry
+
 int32
 Exporter::_ExportThreadEntry(void* cookie)
 {
@@ -93,7 +102,7 @@
        return exporter->_ExportThread();
 }
 
-// _ExportThread
+
 int32
 Exporter::_ExportThread()
 {
@@ -132,10 +141,9 @@
        return ret;
 }
 
-// _Export
+
 status_t
-Exporter::_Export(const Icon* icon,
-                                 const entry_ref* docRef)
+Exporter::_Export(const Icon* icon, const entry_ref* docRef)
 {
        // TODO: reenable the commented out code, but make it work
        // the opposite direction, ie *copy* the file contents

Modified: haiku/trunk/src/apps/icon-o-matic/import_export/Exporter.h
===================================================================
--- haiku/trunk/src/apps/icon-o-matic/import_export/Exporter.h  2011-04-04 
02:21:31 UTC (rev 41175)
+++ haiku/trunk/src/apps/icon-o-matic/import_export/Exporter.h  2011-04-04 
09:18:27 UTC (rev 41176)
@@ -1,9 +1,6 @@
 /*
- * Copyright 2006-2007, Haiku. All rights reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
+ * Copyright 2006, 2007, 2011, Stephan Aßmus <superstippi@xxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
  */
 #ifndef EXPORTER_H
 #define EXPORTER_H
@@ -41,6 +38,8 @@
 
                        void                            SetSelfDestroy(bool 
selfDestroy);
 
+                       void                            WaitForExportThread();
+
  private:
        static  int32                           _ExportThreadEntry(void* 
cookie);
                        int32                           _ExportThread();


Other related posts:

  • » [haiku-commits] r41176 - haiku/trunk/src/apps/icon-o-matic/import_export - superstippi