mirror of https://github.com/KLayout/klayout.git
[consider merging] avoid a warning on writing cells/files in 'under_construction' mode when there is nothing to update
This commit is contained in:
parent
6a9269a9ae
commit
53c173d01e
|
|
@ -1780,7 +1780,7 @@ Layout::force_update ()
|
||||||
// NOTE: the assumption is that either one thread is writing or
|
// NOTE: the assumption is that either one thread is writing or
|
||||||
// multiple threads are reading. Hence, we do not need to lock hier_dirty() or bboxes_dirty().
|
// multiple threads are reading. Hence, we do not need to lock hier_dirty() or bboxes_dirty().
|
||||||
// We still do double checking as another thread might do the update as well.
|
// We still do double checking as another thread might do the update as well.
|
||||||
if (! hier_dirty () && ! bboxes_dirty ()) {
|
if (! update_needed ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1829,10 +1829,16 @@ Layout::update () const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Layout::update_needed () const
|
||||||
|
{
|
||||||
|
return hier_dirty () || bboxes_dirty ();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Layout::do_update ()
|
Layout::do_update ()
|
||||||
{
|
{
|
||||||
if (! hier_dirty () && ! bboxes_dirty ()) {
|
if (! update_needed ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1619,6 +1619,14 @@ public:
|
||||||
*/
|
*/
|
||||||
top_down_const_iterator end_top_cells () const;
|
top_down_const_iterator end_top_cells () const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets a value indicating whether an update is needed
|
||||||
|
*
|
||||||
|
* If this value is false, update or force_update will not
|
||||||
|
* do anything.
|
||||||
|
*/
|
||||||
|
bool update_needed () const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Provide a const version of the update method
|
* @brief Provide a const version of the update method
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ Writer::write (db::Layout &layout, tl::OutputStream &stream)
|
||||||
{
|
{
|
||||||
tl::SelfTimer timer (tl::verbosity () >= 21, tl::to_string (tr ("Writing file: ")) + stream.path ());
|
tl::SelfTimer timer (tl::verbosity () >= 21, tl::to_string (tr ("Writing file: ")) + stream.path ());
|
||||||
|
|
||||||
if (layout.under_construction ()) {
|
if (layout.under_construction () && layout.update_needed ()) {
|
||||||
tl::warn << tl::to_string (tr ("Cannot properly write a layout that is under construction - forcing update."));
|
tl::warn << tl::to_string (tr ("Cannot properly write a layout that is under construction - forcing update."));
|
||||||
layout.force_update ();
|
layout.force_update ();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1758,6 +1758,13 @@ Class<db::Layout> decl_Layout ("db", "Layout",
|
||||||
"is ongoing or the layout is brought into invalid state by\n"
|
"is ongoing or the layout is brought into invalid state by\n"
|
||||||
"\"start_changes\".\n"
|
"\"start_changes\".\n"
|
||||||
) +
|
) +
|
||||||
|
gsi::method ("update_needed", &db::Layout::update_needed,
|
||||||
|
"@brief Gets a value indicating whether the Layout object needs an update\n"
|
||||||
|
"If this method returns false, \\update will not do anything. This is useful to force an update at "
|
||||||
|
"specific times during 'under_construction' conditions.\n"
|
||||||
|
"\n"
|
||||||
|
"This method has been introduced in version 0.30.4."
|
||||||
|
) +
|
||||||
gsi::method ("update", (void (db::Layout::*) ()) &db::Layout::force_update,
|
gsi::method ("update", (void (db::Layout::*) ()) &db::Layout::force_update,
|
||||||
"@brief Updates the internals of the layout\n"
|
"@brief Updates the internals of the layout\n"
|
||||||
"This method updates the internal state of the layout. Usually this is done automatically\n"
|
"This method updates the internal state of the layout. Usually this is done automatically\n"
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,9 @@ TEST(2)
|
||||||
EXPECT_EQ (g.hier_generation_id (), size_t (3));
|
EXPECT_EQ (g.hier_generation_id (), size_t (3));
|
||||||
|
|
||||||
g.clear ();
|
g.clear ();
|
||||||
|
EXPECT_EQ (g.update_needed (), true);
|
||||||
g.update ();
|
g.update ();
|
||||||
|
EXPECT_EQ (g.update_needed (), false);
|
||||||
el.reset ();
|
el.reset ();
|
||||||
EXPECT_EQ (g.hier_generation_id (), size_t (4));
|
EXPECT_EQ (g.hier_generation_id (), size_t (4));
|
||||||
|
|
||||||
|
|
@ -387,7 +389,9 @@ TEST(3)
|
||||||
EXPECT_EQ (el.hier_dirty, true);
|
EXPECT_EQ (el.hier_dirty, true);
|
||||||
|
|
||||||
el.reset ();
|
el.reset ();
|
||||||
|
EXPECT_EQ (g.update_needed (), true);
|
||||||
g.update ();
|
g.update ();
|
||||||
|
EXPECT_EQ (g.update_needed (), false);
|
||||||
|
|
||||||
top->shapes (0).insert (db::Box (0, 0, 10, 20));
|
top->shapes (0).insert (db::Box (0, 0, 10, 20));
|
||||||
top->shapes (1).insert (db::Box (0, 0, 10, 20));
|
top->shapes (1).insert (db::Box (0, 0, 10, 20));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue