Fix CID 885 by creating the image struct later.

Also small style fixes.
Added a TODO about unloading the addon.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38240 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2010-08-18 16:11:18 +00:00
parent ab45ec86ab
commit 5026e5cca4

View File

@ -251,48 +251,62 @@ BMailChainRunner::Init()
);
_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 @@ BMailChainRunner::Init()
return big_err;
}
void
BMailChainRunner::MessageReceived(BMessage *msg)
{