Removed error when optional ext dep is missing (bug 5112, r=fyren).
Removed error when optional ext dep is missing (
bug 5112, r=fyren).
1.1 --- a/core/ExtensionSys.cpp Tue Oct 11 22:50:21 2011 -0400
1.2 +++ b/core/ExtensionSys.cpp Tue Oct 11 22:51:24 2011 -0400
1.3 @@ -372,6 +372,11 @@
1.4 return m_RealFile.c_str();
1.5 }
1.6
1.7 +const char *CExtension::GetPath() const
1.8 +{
1.9 + return m_Path.c_str();
1.10 +}
1.11 +
1.12 IdentityToken_t *CExtension::GetIdentity()
1.13 {
1.14 return m_pIdentToken;
1.15 @@ -580,7 +585,7 @@
1.16 }
1.17 }
1.18
1.19 -IExtension *CExtensionManager::LoadAutoExtension(const char *path)
1.20 +IExtension *CExtensionManager::LoadAutoExtension(const char *path, bool bErrorOnMissing)
1.21 {
1.22 /* Remove platform extension if it's there. Compat hack. */
1.23 const char *ext = g_LibSys.GetFileExtension(path);
1.24 @@ -589,7 +594,7 @@
1.25 char path2[PLATFORM_MAX_PATH];
1.26 UTIL_Format(path2, sizeof(path2), "%s", path);
1.27 path2[strlen(path) - strlen(PLATFORM_LIB_EXT) - 1] = '\0';
1.28 - return LoadAutoExtension(path2);
1.29 + return LoadAutoExtension(path2, bErrorOnMissing);
1.30 }
1.31
1.32 IExtension *pAlready;
1.33 @@ -608,7 +613,11 @@
1.34
1.35 if (!p->Load(error, sizeof(error)) || !p->IsLoaded())
1.36 {
1.37 - g_Logger.LogError("[SM] Unable to load extension \"%s\": %s", path, error);
1.38 + if (bErrorOnMissing || g_LibSys.IsPathFile(p->GetPath()))
1.39 + {
1.40 + g_Logger.LogError("[SM] Unable to load extension \"%s\": %s", path, error);
1.41 + }
1.42 +
1.43 p->SetError(error);
1.44 }
1.45
2.1 --- a/core/ExtensionSys.h Tue Oct 11 22:50:21 2011 -0400
2.2 +++ b/core/ExtensionSys.h Tue Oct 11 22:51:24 2011 -0400
2.3 @@ -66,6 +66,7 @@
2.4 public: //IExtension
2.5 IExtensionInterface *GetAPI();
2.6 const char *GetFilename();
2.7 + const char *GetPath() const;
2.8 IdentityToken_t *GetIdentity();
2.9 ITERATOR *FindFirstDependency(IExtension **pOwner, SMInterface **pInterface);
2.10 bool FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface);
2.11 @@ -163,7 +164,7 @@
2.12 public: //IRootConsoleCommand
2.13 void OnRootConsoleCommand(const char *cmdname, const CCommand &command);
2.14 public:
2.15 - IExtension *LoadAutoExtension(const char *path);
2.16 + IExtension *LoadAutoExtension(const char *path, bool bErrorOnMissing=true);
2.17 void BindDependency(IExtension *pOwner, IfaceInfo *pInfo);
2.18 void AddInterface(IExtension *pOwner, SMInterface *pInterface);
2.19 void BindChildPlugin(IExtension *pParent, CPlugin *pPlugin);
3.1 --- a/core/PluginSys.cpp Tue Oct 11 22:50:21 2011 -0400
3.2 +++ b/core/PluginSys.cpp Tue Oct 11 22:51:24 2011 -0400
3.3 @@ -1308,7 +1308,8 @@
3.4 if (ext->autoload)
3.5 {
3.6 g_LibSys.PathFormat(path, PLATFORM_MAX_PATH, "%s", file);
3.7 - g_Extensions.LoadAutoExtension(path);
3.8 + bool bErrorOnMissing = ext->required ? true : false;
3.9 + g_Extensions.LoadAutoExtension(path, bErrorOnMissing);
3.10 }
3.11 }
3.12 else if (pass == 2)