Enhancement to layer binding for images: now saving as img::ObjectV2 if layer binding is present. This does not break old KLayout versions trying to read session files. But old KLayout version will still crash when trying to save such a session.

This commit is contained in:
Matthias Koefferlein 2025-09-07 22:51:31 +02:00
parent aa9d951cf7
commit aba1f87b0d
1 changed files with 10 additions and 1 deletions

View File

@ -1358,6 +1358,9 @@ Object::from_string (const char *str, const char *base_dir)
color = true;
} else if (ex.test ("mono:")) {
color = false;
} else {
// unrecognized token
return;
}
size_t w = 0;
@ -2499,13 +2502,19 @@ Object::mem_stat (db::MemStatistics *stat, db::MemStatistics::purpose_t purpose,
const char *
Object::class_name () const
{
return "img::Object";
if (m_layer_binding != db::LayerProperties ()) {
// This makes old KLayout versions ignore these images and not crash
return "img::ObjectV2";
} else {
return "img::Object";
}
}
/**
* @brief Registration of the img::Object class in the DUserObject space
*/
static db::DUserObjectDeclaration class_registrar (new db::user_object_factory_impl<img::Object, db::DCoord> ("img::Object"));
static db::DUserObjectDeclaration class_registrar_v2 (new db::user_object_factory_impl<img::Object, db::DCoord> ("img::ObjectV2"));
} // namespace img