mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-15 07:01:18 +02:00
Separate detection of module load failure from error messaging
This commit is contained in:
@@ -95,8 +95,17 @@ Module::~Module()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Module::Load()
|
void Module::ShowLoadFailureError(const wxString &Error)
|
||||||
{
|
{
|
||||||
|
auto ShortName = wxFileName(mName).GetName();
|
||||||
|
AudacityMessageBox(XO("Unable to load the \"%s\" module.\n\nError: %s").Format(ShortName, Error),
|
||||||
|
XO("Module Unsuitable"));
|
||||||
|
wxLogMessage(wxT("Unable to load the module \"%s\". Error: %s"), mName, Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Module::Load(wxString &deferredErrorMessage)
|
||||||
|
{
|
||||||
|
deferredErrorMessage.clear();
|
||||||
// Will this ever happen???
|
// Will this ever happen???
|
||||||
if (mLib->IsLoaded()) {
|
if (mLib->IsLoaded()) {
|
||||||
if (mDispatch) {
|
if (mDispatch) {
|
||||||
@@ -110,10 +119,7 @@ bool Module::Load()
|
|||||||
auto ShortName = wxFileName(mName).GetName();
|
auto ShortName = wxFileName(mName).GetName();
|
||||||
|
|
||||||
if (!mLib->Load(mName, wxDL_NOW | wxDL_QUIET | wxDL_GLOBAL)) {
|
if (!mLib->Load(mName, wxDL_NOW | wxDL_QUIET | wxDL_GLOBAL)) {
|
||||||
auto Error = wxString(wxSysErrorMsg());
|
deferredErrorMessage = wxString(wxSysErrorMsg());
|
||||||
AudacityMessageBox(XO("Unable to load the \"%s\" module.\n\nError: %s").Format(ShortName, Error),
|
|
||||||
XO("Module Unsuitable"));
|
|
||||||
wxLogMessage(wxT("Unable to load the module \"%s\". Error: %s"), mName, Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,8 +330,9 @@ void ModuleManager::Initialize()
|
|||||||
ModulePrefs::SetModuleStatus( files[i], kModuleFailed );
|
ModulePrefs::SetModuleStatus( files[i], kModuleFailed );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
wxString Error;
|
||||||
auto umodule = std::make_unique<Module>(files[i]);
|
auto umodule = std::make_unique<Module>(files[i]);
|
||||||
if (umodule->Load()) // it will get rejected if there are version problems
|
if (umodule->Load(Error)) // it will get rejected if there are version problems
|
||||||
{
|
{
|
||||||
auto module = umodule.get();
|
auto module = umodule.get();
|
||||||
|
|
||||||
@@ -366,6 +373,9 @@ void ModuleManager::Initialize()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (!Error.empty()) {
|
||||||
|
umodule->ShowLoadFailureError(Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
::wxSetWorkingDirectory(saveOldCWD);
|
::wxSetWorkingDirectory(saveOldCWD);
|
||||||
|
|
||||||
|
@@ -41,7 +41,8 @@ public:
|
|||||||
Module(const FilePath & name);
|
Module(const FilePath & name);
|
||||||
virtual ~Module();
|
virtual ~Module();
|
||||||
|
|
||||||
bool Load();
|
void ShowLoadFailureError(const wxString &Error);
|
||||||
|
bool Load(wxString &deferredErrorMessage);
|
||||||
void Unload();
|
void Unload();
|
||||||
bool HasDispatch() { return mDispatch != NULL; };
|
bool HasDispatch() { return mDispatch != NULL; };
|
||||||
int Dispatch(ModuleDispatchTypes type);
|
int Dispatch(ModuleDispatchTypes type);
|
||||||
|
Reference in New Issue
Block a user