diff --git a/src/db/db/gsiDeclDbPCellDeclaration.cc b/src/db/db/gsiDeclDbPCellDeclaration.cc index 5a0c51191..ecbabe2b4 100644 --- a/src/db/db/gsiDeclDbPCellDeclaration.cc +++ b/src/db/db/gsiDeclDbPCellDeclaration.cc @@ -168,6 +168,13 @@ Class decl_PCellParameterStates ("db", "PCellParameterState "\n" "This will return a \\PCellParameterState object that can be used to manipulate the " "parameter state." + ) + + gsi::method ("parameter", static_cast (&db::ParameterStates::parameter), gsi::arg ("name"), + "@brief Gets the parameter by name (const version)\n" + "\n" + "This will return a \\PCellParameterState object which cannot be manipulated, but read.\n" + "\n" + "The const flavor has been introduced in version 0.30.11." ), "@brief Provides access to the parameter states inside a 'callback' implementation of a PCell\n" "\n" diff --git a/src/edt/edt/edtPCellParametersPageBase.cc b/src/edt/edt/edtPCellParametersPageBase.cc index 0f462c285..8fd095060 100644 --- a/src/edt/edt/edtPCellParametersPageBase.cc +++ b/src/edt/edt/edtPCellParametersPageBase.cc @@ -392,6 +392,9 @@ PCellParametersPageBase::State PCellParametersPageBase::get_state () { State s; + if (! mp_page_widget) { + return s; + } s.valid = true; s.v_scroll_position = mp_parameters_area->verticalScrollBar ()->value (); @@ -409,7 +412,7 @@ PCellParametersPageBase::get_state () void PCellParametersPageBase::set_state (const State &s) { - if (s.valid) { + if (s.valid && mp_page_widget) { mp_parameters_area->verticalScrollBar ()->setValue (s.v_scroll_position); mp_parameters_area->horizontalScrollBar ()->setValue (s.h_scroll_position); diff --git a/testdata/ruby/dbPCells.rb b/testdata/ruby/dbPCells.rb index 82e6f5624..38bddbb17 100644 --- a/testdata/ruby/dbPCells.rb +++ b/testdata/ruby/dbPCells.rb @@ -1082,6 +1082,34 @@ class DBPCellParameterStates_TestClass < TestBase end + def test_2 + + pss = RBA::PCellParameterStates::new + assert_equal(pss.has_parameter?("a"), false) + pa = pss.parameter("a") + assert_equal(pss.has_parameter?("a"), true) + + # manipulating the value is reflected in the states collection + pa.value = 17 + assert_equal(pss.parameter("a").value, 17) + + pss_const = pss._to_const_object + assert_equal(pss_const._is_const_object?, true) + + assert_equal(pss_const.has_parameter?("a"), true) + pa = pss_const.parameter("a") + assert_equal(pa.value, 17) + + begin + # can't manipulate the const value + pa.value = 18 + assert_equal(true, false) + rescue => ex + # goes here + end + + end + end load("test_epilogue.rb")