Skip to content

Commit

Permalink
Fixed issue #1522 (Changing ruler/annotation from script weirdly inte…
Browse files Browse the repository at this point in the history
…rferes with pya.Application.commit_config)
  • Loading branch information
Matthias Koefferlein committed Nov 19, 2023
1 parent 8b805d8 commit 9565a55
Showing 1 changed file with 37 additions and 40 deletions.
77 changes: 37 additions & 40 deletions src/ant/ant/antPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,6 @@ namespace ant

static PluginDeclaration *sp_instance = 0;

PluginDeclaration::PluginDeclaration ()
: m_current_template (0),
m_current_template_updated (true), m_templates_updated (true)
{
sp_instance = this;
}

PluginDeclaration::~PluginDeclaration ()
{
sp_instance = 0;
}

PluginDeclaration *
PluginDeclaration::instance ()
{
return sp_instance;
}

static std::vector<ant::Template> make_standard_templates ()
{
std::vector<ant::Template> templates;
Expand Down Expand Up @@ -92,6 +74,24 @@ static std::vector<ant::Template> make_standard_templates ()
return templates;
}

PluginDeclaration::PluginDeclaration ()
: m_current_template (0),
m_current_template_updated (true), m_templates_updated (true)
{
sp_instance = this;
}

PluginDeclaration::~PluginDeclaration ()
{
sp_instance = 0;
}

PluginDeclaration *
PluginDeclaration::instance ()
{
return sp_instance;
}

void
PluginDeclaration::get_options (std::vector < std::pair<std::string, std::string> > &options) const
{
Expand Down Expand Up @@ -281,25 +281,24 @@ PluginDeclaration::update_current_template ()
return;
}

if (m_current_template >= 0 && m_current_template < int (m_templates.size ())) {

std::vector<std::string> menu_entries = mp->menu ()->group ("ruler_mode_group");
for (std::vector<std::string>::const_iterator m = menu_entries.begin (); m != menu_entries.end (); ++m) {
lay::Action *action = mp->menu ()->action (*m);
std::vector<std::string> menu_entries = mp->menu ()->group ("ruler_mode_group");
for (std::vector<std::string>::const_iterator m = menu_entries.begin (); m != menu_entries.end (); ++m) {
lay::Action *action = mp->menu ()->action (*m);
if (m_current_template >= 0 && m_current_template < int (m_templates.size ())) {
action->set_title (m_templates [m_current_template].title ());
} else {
action->set_title (std::string ());
}

if (m_templates.size () > 1) {
}

tl::weak_collection<lay::ConfigureAction>::iterator it = m_actions.begin ();
int index = 0;
for (std::vector<Template>::const_iterator tt = m_templates.begin (); tt != m_templates.end () && it != m_actions.end (); ++tt, ++it, ++index) {
if (it.operator -> ()) {
it->set_checked (index == m_current_template);
}
if (m_templates.size () > 1) {
tl::weak_collection<lay::ConfigureAction>::iterator it = m_actions.begin ();
int index = 0;
for (std::vector<Template>::const_iterator tt = m_templates.begin (); tt != m_templates.end () && it != m_actions.end (); ++tt, ++it, ++index) {
if (it.operator -> ()) {
it->set_checked (index == m_current_template);
}
}

}

m_current_template_updated = false;
Expand All @@ -313,15 +312,13 @@ PluginDeclaration::update_menu ()
return;
}

if (m_current_template < 0 || m_current_template >= int (m_templates.size ())) {
m_current_template = 0;
}

if (m_current_template >= 0 && m_current_template < int (m_templates.size ())) {
std::vector<std::string> menu_entries = mp->menu ()->group ("ruler_mode_group");
for (std::vector<std::string>::const_iterator m = menu_entries.begin (); m != menu_entries.end (); ++m) {
lay::Action *action = mp->menu ()->action (*m);
std::vector<std::string> menu_entries = mp->menu ()->group ("ruler_mode_group");
for (std::vector<std::string>::const_iterator m = menu_entries.begin (); m != menu_entries.end (); ++m) {
lay::Action *action = mp->menu ()->action (*m);
if (m_current_template >= 0 && m_current_template < int (m_templates.size ())) {
action->set_title (m_templates [m_current_template].title ());
} else {
action->set_title (std::string ());
}
}

Expand Down

0 comments on commit 9565a55

Please sign in to comment.