diff --git a/application/ChatProtocolAddOn.cpp b/application/ChatProtocolAddOn.cpp index 2fa16fe..744a3a9 100644 --- a/application/ChatProtocolAddOn.cpp +++ b/application/ChatProtocolAddOn.cpp @@ -27,6 +27,13 @@ ChatProtocolAddOn::ChatProtocolAddOn(image_id image, const char* path, int32 sub } +ChatProtocolAddOn::~ChatProtocolAddOn() +{ + delete fIcon; + unload_add_on(fImage); +} + + status_t ChatProtocolAddOn::InitCheck() const { diff --git a/application/ChatProtocolAddOn.h b/application/ChatProtocolAddOn.h index 4fd4629..aaf7c0a 100644 --- a/application/ChatProtocolAddOn.h +++ b/application/ChatProtocolAddOn.h @@ -17,6 +17,7 @@ class ChatProtocolAddOn { public: ChatProtocolAddOn(image_id image, const char* path, int32 subProto=0); + ~ChatProtocolAddOn(); status_t InitCheck() const; diff --git a/application/ProtocolManager.cpp b/application/ProtocolManager.cpp index d6829ff..ad174f8 100644 --- a/application/ProtocolManager.cpp +++ b/application/ProtocolManager.cpp @@ -47,10 +47,18 @@ ProtocolManager::Init(BDirectory dir, BHandler* target) if (id < 0) continue; - // If add-on's API version fits then load accounts… + // Refuse to load add-on under some circumstances… ChatProtocolAddOn* addOn = new ChatProtocolAddOn(id, path.Path()); - if (addOn->Version() != APP_VERSION) + if (addOn->Version() != APP_VERSION || ProtocolAddOn(addOn->Signature()) != NULL) { + if (addOn->Version() != APP_VERSION) + printf("%s not loaded, due to insufficient version (%i v %i).\n", + addOn->Signature(), addOn->Version(), APP_VERSION); + else if (ProtocolAddOn(addOn->Signature()) != NULL) + printf("%s not loaded, due to another instance already having been loaded.\n", + addOn->Signature()); + delete addOn; continue; + } ret = true; // If add-on has multiple protocols, also load them