qa_eeschema: fix a crash due to LIB_PIN ctor that was using default config values,

but in QA tests, we do not have config values available.
This commit is contained in:
jean-pierre charras 2020-04-14 18:12:15 +02:00
parent a49deec278
commit 4a2a5a9403
3 changed files with 32 additions and 4 deletions

View File

@ -163,6 +163,13 @@ PGM_BASE& Pgm()
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from
// a python script or something else.
PGM_BASE* PgmOrNull()
{
return process;
}
bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
{

View File

@ -153,10 +153,23 @@ LIB_PIN::LIB_PIN( LIB_PART* aParent )
m_attributes = 0; // bit 0 != 0: pin invisible
m_width = 0;
LIBEDIT_SETTINGS* settings = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
// Use the application settings for pin sizes if exists.
// pgm can be nullptr when running a shared lib from a script, not from a kicad appl
PGM_BASE* pgm = PgmOrNull();
if( pgm )
{
LIBEDIT_SETTINGS* settings = pgm->GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
m_length = Mils2iu( settings->m_Defaults.pin_length );
m_numTextSize = Mils2iu( settings->m_Defaults.pin_num_size );
m_nameTextSize = Mils2iu( settings->m_Defaults.pin_name_size );
}
else // Use hardcoded eeschema defaults: libedit settings are not existing.
{
m_length = Mils2iu( 100 );
m_numTextSize = Mils2iu( 50 );
m_nameTextSize = Mils2iu( 50 );
}
}

View File

@ -113,6 +113,14 @@ PGM_BASE& Pgm()
return program;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from
// a python script or something else.
// Therefore here return always nullptr
PGM_BASE* PgmOrNull()
{
return nullptr;
}
KIFACE_I& Kiface()
{