Skip to content

Commit

Permalink
fix c module decoder->open invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriSizuku committed Nov 21, 2024
1 parent d9e4a94 commit 3bb84fe
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/core_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bool TileSolver::LoadDecoder(wxFileName pluginfile)
}
wxString luastr;
f.ReadAll(&luastr);
auto status = decoder->open(luastr.c_str().AsChar(), &decoder->context);
status = decoder->open(luastr.c_str().AsChar(), &decoder->context);
if(!PLUGIN_SUCCESS(status))
{
wxLogError("[TileSolver::LoadDecoder] lua %s, decoder->open failed, msg: \n %s", filepath, decoder->msg);
Expand All @@ -60,28 +60,34 @@ bool TileSolver::LoadDecoder(wxFileName pluginfile)
}
else if ("." + pluginfile.GetExt() == wxDynamicLibrary::GetDllExt()) // load c module
{
auto filepath = pluginfile.GetFullPath();
if(m_cmodule.IsLoaded()) m_cmodule.Unload();
if(!m_cmodule.Load(pluginfile.GetFullPath()))
{
auto filepath = pluginfile.GetFullPath();
if(m_cmodule.IsLoaded()) m_cmodule.Unload();
if(!m_cmodule.Load(pluginfile.GetFullPath()))
{
wxLogError("[TileSolver::LoadDecoder] cmodule %s, open file failed", filepath);
return false;
}
decoder = (struct tile_decoder_t*)m_cmodule.GetSymbol("decoder"); // try find decoder struct
if(!decoder) // try to find function get_decoder
{
}
decoder = (struct tile_decoder_t*)m_cmodule.GetSymbol("decoder"); // try find decoder struct
if(!decoder) // try to find function get_decoder
{
auto get_decoder = (API_get_decoder)m_cmodule.GetSymbol("get_decoder");
if(get_decoder)
{
decoder = get_decoder();
}
}
if(!decoder)
{
}
if(!decoder)
{
m_cmodule.Unload();
wxLogError("[TileSolver::LoadDecoder] cmodule %s, can not find decoder", filepath);
return false;
}
}
status = decoder->open(m_pluginfile.GetFullName().c_str().AsChar(), &decoder->context);
if(!PLUGIN_SUCCESS(status))
{
wxLogError("[TileSolver::LoadDecoder] lua %s, decoder->open failed, msg: \n %s", filepath, decoder->msg);
return false;
}
}
if (!decoder)
{
Expand Down

0 comments on commit 3bb84fe

Please sign in to comment.