From 45b9ce0cd31dd24c79f179feffaeebe8f20a4f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 24 Aug 2010 09:46:55 +0000 Subject: [PATCH] * It's easier if we deal with just entry_refs instead of converting to BEntry and back to entry_ref. This ommits a check to BEntry::InitCheck(), but AddOnMonitor should pass us only valid entry_refs. * Removed no longer valid TODO. TODO: There is still some problem with reloading add-ons, once they have been reloaded, they fail to instantiate properly, as if the entry_ref is pointing to the wrong node. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38328 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/media/AddOnManager.cpp | 33 ++++++++---------------------- src/servers/media/AddOnManager.h | 4 ++-- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/servers/media/AddOnManager.cpp b/src/servers/media/AddOnManager.cpp index 858e2af09d..12328ac6d6 100644 --- a/src/servers/media/AddOnManager.cpp +++ b/src/servers/media/AddOnManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2004-2009, Haiku. All rights reserved. + * Copyright 2004-2010, Haiku. All rights reserved. * Distributed under the terms of the MIT license. * * Authors: @@ -252,9 +252,7 @@ AddOnManager::_RegisterAddOns() entry_ref ref; make_entry_ref(entryInfo->dir_nref.device, entryInfo->dir_nref.node, entryInfo->name, &ref); - BEntry entry(&ref, false); - if (entry.InitCheck() == B_OK) - fManager->_RegisterAddOn(entry); + fManager->_RegisterAddOn(ref); } virtual void AddOnDisabled(const add_on_entry_info* entryInfo) @@ -262,9 +260,7 @@ AddOnManager::_RegisterAddOns() entry_ref ref; make_entry_ref(entryInfo->dir_nref.device, entryInfo->dir_nref.node, entryInfo->name, &ref); - BEntry entry(&ref, false); - if (entry.InitCheck() == B_OK) - fManager->_UnregisterAddOn(entry); + fManager->_UnregisterAddOn(ref); } virtual void AddOnRemoved(const add_on_entry_info* entryInfo) @@ -314,20 +310,16 @@ AddOnManager::_RegisterAddOns() status_t -AddOnManager::_RegisterAddOn(BEntry& entry) +AddOnManager::_RegisterAddOn(const entry_ref& ref) { - BPath path(&entry); - - entry_ref ref; - status_t status = entry.GetRef(&ref); - if (status < B_OK) - return status; + BPath path(&ref); printf("AddOnManager::_RegisterAddOn(): trying to load \"%s\"\n", path.Path()); ImageLoader loader(path); - if ((status = loader.InitCheck()) != B_OK) + status_t status = loader.InitCheck(); + if (status != B_OK) return status; MediaPlugin* (*instantiate_plugin_func)(); @@ -346,8 +338,6 @@ AddOnManager::_RegisterAddOn(BEntry& entry) return B_ERROR; } - // TODO: Remove any old formats describing this add-on!! - ReaderPlugin* reader = dynamic_cast(plugin); if (reader != NULL) _RegisterReader(reader, ref); @@ -371,19 +361,14 @@ AddOnManager::_RegisterAddOn(BEntry& entry) status_t -AddOnManager::_UnregisterAddOn(BEntry& entry) +AddOnManager::_UnregisterAddOn(const entry_ref& ref) { -BPath path(&entry); +BPath path(&ref); printf("AddOnManager::_UnregisterAddOn(): trying to unload \"%s\"\n", path.Path()); BAutolock locker(fLock); - entry_ref ref; - status_t status = entry.GetRef(&ref); - if (status != B_OK) - return status; - // Remove any Readers exported by this add-on reader_info* readerInfo; for (fReaderList.Rewind(); fReaderList.GetNext(&readerInfo);) { diff --git a/src/servers/media/AddOnManager.h b/src/servers/media/AddOnManager.h index 3f0386a8e3..f1a8363cd6 100644 --- a/src/servers/media/AddOnManager.h +++ b/src/servers/media/AddOnManager.h @@ -56,8 +56,8 @@ public: private: void _RegisterAddOns(); - status_t _RegisterAddOn(BEntry& entry); - status_t _UnregisterAddOn(BEntry& entry); + status_t _RegisterAddOn(const entry_ref& ref); + status_t _UnregisterAddOn(const entry_ref& ref); void _RegisterReader(ReaderPlugin* reader, const entry_ref& ref);