Fixed crash with separator - #158.
This commit is contained in:
parent
a889db4f6b
commit
ae9a6e7d61
@ -69,9 +69,11 @@ void PlainToolButton::setChecked(bool checked) {
|
||||
void PlainToolButton::reactOnActionChange(QAction *action) {
|
||||
QAction *real_action = action == NULL ? qobject_cast<QAction*>(sender()) : action;
|
||||
|
||||
if (real_action != NULL) {
|
||||
setEnabled(real_action->isEnabled());
|
||||
setCheckable(real_action->isCheckable());
|
||||
setChecked(real_action->isChecked());
|
||||
setIcon(real_action->icon());
|
||||
setToolTip(real_action->toolTip());
|
||||
}
|
||||
}
|
||||
|
@ -151,20 +151,29 @@ void StatusBar::loadChangeableActions(const QStringList &action_names) {
|
||||
|
||||
widget_to_add->setVisible(false);
|
||||
}
|
||||
else {
|
||||
if (action_name == SEPARATOR_ACTION_NAME) {
|
||||
QLabel *lbl = new QLabel(QSL("•"));
|
||||
|
||||
widget_to_add = lbl;
|
||||
action_to_add = new QAction(this);
|
||||
action_to_add->setProperty("should_remove_action", true);
|
||||
}
|
||||
else {
|
||||
// Add originally toolbar action.
|
||||
PlainToolButton *tool_button = new PlainToolButton(this);
|
||||
|
||||
tool_button->reactOnActionChange(matching_action);
|
||||
|
||||
action_to_add = matching_action;
|
||||
widget_to_add = tool_button;
|
||||
action_to_add = matching_action;
|
||||
|
||||
matching_action->setProperty("should_remove", true);
|
||||
connect(tool_button, SIGNAL(clicked(bool)), matching_action, SLOT(trigger()));
|
||||
connect(matching_action, SIGNAL(changed()), tool_button, SLOT(reactOnActionChange()));
|
||||
}
|
||||
|
||||
action_to_add->setProperty("should_remove_widget", true);
|
||||
}
|
||||
|
||||
action_to_add->setProperty("widget", QVariant::fromValue((void*) widget_to_add));
|
||||
addPermanentWidget(widget_to_add);
|
||||
addAction(action_to_add);
|
||||
@ -185,18 +194,23 @@ void StatusBar::clear() {
|
||||
while (!actions().isEmpty()) {
|
||||
QAction *act = actions().at(0);
|
||||
QWidget *widget = act->property("widget").isValid() ? static_cast<QWidget*>(act->property("widget").value<void*>()) : NULL;
|
||||
bool should_remove = act->property("remove_widget").isValid();
|
||||
bool should_remove_widget = act->property("should_remove_widget").isValid();
|
||||
bool should_remove_action = act->property("should_remove_action").isValid();
|
||||
|
||||
removeAction(act);
|
||||
|
||||
if (widget != NULL) {
|
||||
removeWidget(widget);
|
||||
widget->setVisible(false);
|
||||
|
||||
if (should_remove) {
|
||||
if (should_remove_widget) {
|
||||
widget->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
removeAction(act);
|
||||
if (should_remove_action) {
|
||||
act->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user