Browse Source

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.
pull/16/head
jean-pierre charras 6 years ago
parent
commit
4a2a5a9403
  1. 7
      eeschema/eeschema.cpp
  2. 21
      eeschema/lib_pin.cpp
  3. 8
      qa/eeschema/mocks_eeschema.cpp

7
eeschema/eeschema.cpp

@ -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 )
{

21
eeschema/lib_pin.cpp

@ -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>();
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 );
// 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 );
}
}

8
qa/eeschema/mocks_eeschema.cpp

@ -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()
{

Loading…
Cancel
Save