Fix loading of symbols from libs through non-chooser paths
Allow calling PLUGIN::LoadSymbol directly when outside the threaded loader
This commit is contained in:
parent
49354e52a8
commit
9a8ee2ca50
|
@ -345,6 +345,8 @@ void SYMBOL_LIB_TABLE::LoadSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
|
||||||
SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true );
|
SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true );
|
||||||
wxCHECK( row && row->plugin, /* void */ );
|
wxCHECK( row && row->plugin, /* void */ );
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock( row->GetMutex() );
|
||||||
|
|
||||||
wxString options = row->GetOptions();
|
wxString options = row->GetOptions();
|
||||||
|
|
||||||
if( aPowerSymbolsOnly )
|
if( aPowerSymbolsOnly )
|
||||||
|
@ -375,7 +377,13 @@ LIB_SYMBOL* SYMBOL_LIB_TABLE::LoadSymbol( const wxString& aNickname, const wxStr
|
||||||
{
|
{
|
||||||
SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true );
|
SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true );
|
||||||
|
|
||||||
if( !row || !row->plugin || !row->GetIsLoaded() )
|
if( !row || !row->plugin )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
// If another thread is loading this library at the moment; continue
|
||||||
|
std::unique_lock<std::mutex> lock( row->GetMutex(), std::try_to_lock );
|
||||||
|
|
||||||
|
if( !lock.owns_lock() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
LIB_SYMBOL* symbol = row->plugin->LoadSymbol( row->GetFullURI( true ), aSymbolName,
|
LIB_SYMBOL* symbol = row->plugin->LoadSymbol( row->GetFullURI( true ), aSymbolName,
|
||||||
|
|
|
@ -180,6 +180,8 @@ public:
|
||||||
|
|
||||||
void SetParent( LIB_TABLE* aParent ) { m_parent = aParent; }
|
void SetParent( LIB_TABLE* aParent ) { m_parent = aParent; }
|
||||||
|
|
||||||
|
std::mutex& GetMutex() { return m_loadMutex; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the constant #PROPERTIES for this library (#LIB_TABLE_ROW). These are
|
* Return the constant #PROPERTIES for this library (#LIB_TABLE_ROW). These are
|
||||||
* the "options" in a table.
|
* the "options" in a table.
|
||||||
|
@ -244,6 +246,8 @@ private:
|
||||||
LIB_TABLE* m_parent; ///< Pointer to the table this row lives in (maybe null)
|
LIB_TABLE* m_parent; ///< Pointer to the table this row lives in (maybe null)
|
||||||
|
|
||||||
std::unique_ptr< PROPERTIES > properties;
|
std::unique_ptr< PROPERTIES > properties;
|
||||||
|
|
||||||
|
std::mutex m_loadMutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue