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:
parent
a49deec278
commit
4a2a5a9403
|
@ -163,6 +163,13 @@ PGM_BASE& Pgm()
|
||||||
return *process;
|
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 )
|
bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
|
||||||
{
|
{
|
||||||
|
|
|
@ -153,10 +153,23 @@ LIB_PIN::LIB_PIN( LIB_PART* aParent )
|
||||||
m_attributes = 0; // bit 0 != 0: pin invisible
|
m_attributes = 0; // bit 0 != 0: pin invisible
|
||||||
m_width = 0;
|
m_width = 0;
|
||||||
|
|
||||||
LIBEDIT_SETTINGS* settings = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
|
// Use the application settings for pin sizes if exists.
|
||||||
m_length = Mils2iu( settings->m_Defaults.pin_length );
|
// pgm can be nullptr when running a shared lib from a script, not from a kicad appl
|
||||||
m_numTextSize = Mils2iu( settings->m_Defaults.pin_num_size );
|
PGM_BASE* pgm = PgmOrNull();
|
||||||
m_nameTextSize = Mils2iu( settings->m_Defaults.pin_name_size );
|
|
||||||
|
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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,14 @@ PGM_BASE& Pgm()
|
||||||
return program;
|
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()
|
KIFACE_I& Kiface()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue