forked from qt-creator/qt-creator
ActionManager: Update proxy action more directly
The proxy action was updating from the actual action delayed by a
QueuedConnection. This was introduced in
c3772bfd4c to avoid disconnecting and
reconnecting to QAction::changed while handling that same
QAction::changed.
This introduces a delay between the actual action's change and when it
is reflected in the proxy action.
ProxyAction::update only needs to disconnect signals that would trigger
because of the changes done to the ProxyAction. So it doesn't need to
disconnect/connect from the actual Action's changed signal. Only
disconnect/connect the signals that we really need, and get rid of the
QueuedConnection again.
Fixes: QTCREATORBUG-26363
Change-Id: I2b851af35fcb4a3931b645896dd77477cee79812
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -63,17 +63,16 @@ void ProxyAction::disconnectAction()
|
|||||||
{
|
{
|
||||||
if (m_action) {
|
if (m_action) {
|
||||||
disconnect(m_action.data(), &QAction::changed, this, &ProxyAction::actionChanged);
|
disconnect(m_action.data(), &QAction::changed, this, &ProxyAction::actionChanged);
|
||||||
disconnect(this, &QAction::triggered, m_action.data(), &QAction::triggered);
|
disconnect(this, &ProxyAction::triggered, m_action.data(), &QAction::triggered);
|
||||||
disconnect(this, &QAction::toggled, m_action.data(), &QAction::setChecked);
|
disconnect(this, &ProxyAction::toggled, m_action.data(), &QAction::setChecked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProxyAction::connectAction()
|
void ProxyAction::connectAction()
|
||||||
{
|
{
|
||||||
if (m_action) {
|
if (m_action) {
|
||||||
connect(m_action.data(), &QAction::changed, this, &ProxyAction::actionChanged,
|
connect(m_action.data(), &QAction::changed, this, &ProxyAction::actionChanged);
|
||||||
Qt::QueuedConnection);
|
connect(this, &ProxyAction::triggered, m_action.data(), &QAction::triggered);
|
||||||
connect(this, &QAction::triggered, m_action.data(), &QAction::triggered);
|
|
||||||
connect(this, &ProxyAction::toggled, m_action.data(), &QAction::setChecked);
|
connect(this, &ProxyAction::toggled, m_action.data(), &QAction::setChecked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,8 +113,7 @@ void ProxyAction::update(QAction *action, bool initialize)
|
|||||||
{
|
{
|
||||||
if (!action)
|
if (!action)
|
||||||
return;
|
return;
|
||||||
disconnectAction();
|
disconnect(this, &ProxyAction::changed, this, &ProxyAction::updateToolTipWithKeySequence);
|
||||||
disconnect(this, &QAction::changed, this, &ProxyAction::updateToolTipWithKeySequence);
|
|
||||||
if (initialize) {
|
if (initialize) {
|
||||||
setSeparator(action->isSeparator());
|
setSeparator(action->isSeparator());
|
||||||
setMenuRole(action->menuRole());
|
setMenuRole(action->menuRole());
|
||||||
@@ -136,12 +134,17 @@ void ProxyAction::update(QAction *action, bool initialize)
|
|||||||
setCheckable(action->isCheckable());
|
setCheckable(action->isCheckable());
|
||||||
|
|
||||||
if (!initialize) {
|
if (!initialize) {
|
||||||
setChecked(action->isChecked());
|
if (isChecked() != action->isChecked()) {
|
||||||
|
if (m_action)
|
||||||
|
disconnect(this, &ProxyAction::toggled, m_action.data(), &QAction::setChecked);
|
||||||
|
setChecked(action->isChecked());
|
||||||
|
if (m_action)
|
||||||
|
connect(this, &ProxyAction::toggled, m_action.data(), &QAction::setChecked);
|
||||||
|
}
|
||||||
setEnabled(action->isEnabled());
|
setEnabled(action->isEnabled());
|
||||||
setVisible(action->isVisible());
|
setVisible(action->isVisible());
|
||||||
}
|
}
|
||||||
connectAction();
|
connect(this, &ProxyAction::changed, this, &ProxyAction::updateToolTipWithKeySequence);
|
||||||
connect(this, &QAction::changed, this, &ProxyAction::updateToolTipWithKeySequence);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProxyAction::shortcutVisibleInToolTip() const
|
bool ProxyAction::shortcutVisibleInToolTip() const
|
||||||
|
|||||||
Reference in New Issue
Block a user