[haiku-commits] r38240 - haiku/trunk/src/kits/mail

  • From: stefano.ceccherini@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 18 Aug 2010 18:11:19 +0200 (CEST)

Author: jackburton
Date: 2010-08-18 18:11:18 +0200 (Wed, 18 Aug 2010)
New Revision: 38240
Changeset: http://dev.haiku-os.org/changeset/38240

Modified:
   haiku/trunk/src/kits/mail/ChainRunner.cpp
Log:
Fix CID 885 by creating the image struct later.
Also small style fixes.
Added a TODO about unloading the addon.


Modified: haiku/trunk/src/kits/mail/ChainRunner.cpp
===================================================================
--- haiku/trunk/src/kits/mail/ChainRunner.cpp   2010-08-18 15:45:24 UTC (rev 
38239)
+++ haiku/trunk/src/kits/mail/ChainRunner.cpp   2010-08-18 16:11:18 UTC (rev 
38240)
@@ -251,48 +251,62 @@
        );
 
        _status->Lock();
-       _statview = 
_status->NewStatusView(desc.String(),_chain->ChainDirection() == outbound);
+       _statview = _status->NewStatusView(desc.String(), 
_chain->ChainDirection() == outbound);
        _status->Unlock();
 
        BMessage settings;
-       for (int32 i = 0; _chain->GetFilter(i,&settings,&addon) >= B_OK; i++) {
-               struct filter_image *image = new struct filter_image;
+       for (int32 i = 0; _chain->GetFilter(i, &settings, &addon) >= B_OK; i++) 
{
                BPath path(&addon);
-               BMailFilter *(* instantiate)(BMessage *,BMailChainRunner *);
+               BMailFilter *(*instantiate)(BMessage*, BMailChainRunner*);
 
-               image->id = load_add_on(path.Path());
-
-               if (image->id < B_OK) {
+               image_id imageId = load_add_on(path.Path());
+                                       
+               if (imageId < B_OK) {
                        BString error;
                        MDR_DIALECT_CHOICE (
-                               error << "Error loading the mail addon " << 
path.Path() << " from chain " << _chain->Name() << ": " << strerror(image->id);
+                               error << "Error loading the mail addon "
+                                       << path.Path() << " from chain " << 
_chain->Name()
+                                       << ": " << strerror(imageId);
                                ShowError(error.String());,
-                               error << "メールアドオン " << path.Path() << " を " << 
_chain->Name() << "から読み込む際にエラーが発生しました: " << strerror(image->id);
+                               error << "メールアドオン " << path.Path()
+                                       << " を " << _chain->Name() 
+                                       << "から読み込む際にエラーが発生しました: "
+                                       << strerror(imageId);
+                                       
                                ShowError(error.String());
                        )
-                       return image->id;
+                       return imageId;
                }
 
-               status_t err = 
get_image_symbol(image->id,"instantiate_mailfilter",B_SYMBOL_TYPE_TEXT,(void 
**)&instantiate);
+               status_t err = get_image_symbol(imageId,
+                       "instantiate_mailfilter", B_SYMBOL_TYPE_TEXT,
+                       (void **)&instantiate);
                if (err < B_OK) {
                        BString error;
                        MDR_DIALECT_CHOICE (
-                               error << "Error loading the mail addon " << 
path.Path() << " from chain " << _chain->Name()
+                               error << "Error loading the mail addon " << 
path.Path()
+                                       << " from chain " << _chain->Name()
                                        << ": the addon does not seem to be a 
mail addon (missing symbol instantiate_mailfilter).";
                                ShowError(error.String());,
-                               error << "メールアドオン " << path.Path() << " を " << 
_chain->Name() << "から読み込む際にエラーが発生しました"
-                                               << ": 
そのアドオンはメールアドオンではないようです(instantiate_mailfilterシンボルがありません)";
+                               error << "メールアドオン " << path.Path() << " を "
+                                       << _chain->Name() << 
"から読み込む際にエラーが発生しました"
+                                       << ": 
そのアドオンはメールアドオンではないようです(instantiate_mailfilterシンボルがありません)";
                                ShowError(error.String());
                        )
 
                        err = -1;
+                       
+                       // TODO: unload_add_on() ?
                        return err;
                }
 
+               filter_image* image = new filter_image;
+               
+               image->id = imageId;
                image->settings = new BMessage(settings);
-
-               image->settings->AddInt32("chain",_chain->ID());
-               image->filter = (*instantiate)(image->settings,this);
+               image->settings->AddInt32("chain", _chain->ID());
+               image->filter = (*instantiate)(image->settings, this);
+               
                addons.AddItem(image);
 
                if ((big_err = image->filter->InitCheck()) != B_OK) {
@@ -303,6 +317,7 @@
        return big_err;
 }
 
+
 void
 BMailChainRunner::MessageReceived(BMessage *msg)
 {


Other related posts:

  • » [haiku-commits] r38240 - haiku/trunk/src/kits/mail - stefano . ceccherini