Commit a8a2c080 authored by David Faure's avatar David Faure

KFileWidget: fix crash on FreeBSD (from the destructor)

KFileWidget::eventFilter()
(QEvent::Destroy event)
QWidget::~QWidget()
KDirOperator::~KDirOperator
KFileWidgetPrivate::~KFileWidgetPrivate
KFileWidget::~KFileWidget

In that event filter, the d pointer is in the process of being deleted,
better not use it. The event filter is only about key events anyway,
skip it for everything else.
parent d0df7a02
......@@ -1849,33 +1849,35 @@ bool KFileWidget::eventFilter(QObject *watched, QEvent *event)
const bool res = QWidget::eventFilter(watched, event);
QKeyEvent *keyEvent = dynamic_cast<QKeyEvent *>(event);
if (watched == d->m_iconSizeSlider && keyEvent) {
if (keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Up ||
keyEvent->key() == Qt::Key_Right || keyEvent->key() == Qt::Key_Down) {
d->slotIconSizeSliderMoved(d->m_iconSizeSlider->value());
}
} else if (watched == d->m_locationEdit && event->type() == QEvent::KeyPress) {
if (keyEvent->modifiers() & Qt::AltModifier) {
switch (keyEvent->key()) {
case Qt::Key_Up:
d->m_ops->actionCollection()->action(QStringLiteral("up"))->trigger();
break;
case Qt::Key_Left:
d->m_ops->actionCollection()->action(QStringLiteral("back"))->trigger();
break;
case Qt::Key_Right:
d->m_ops->actionCollection()->action(QStringLiteral("forward"))->trigger();
break;
default:
break;
if (keyEvent) {
if (watched == d->m_iconSizeSlider) {
if (keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Up ||
keyEvent->key() == Qt::Key_Right || keyEvent->key() == Qt::Key_Down) {
d->slotIconSizeSliderMoved(d->m_iconSizeSlider->value());
}
} else if (watched == d->m_locationEdit && event->type() == QEvent::KeyPress) {
if (keyEvent->modifiers() & Qt::AltModifier) {
switch (keyEvent->key()) {
case Qt::Key_Up:
d->m_ops->actionCollection()->action(QStringLiteral("up"))->trigger();
break;
case Qt::Key_Left:
d->m_ops->actionCollection()->action(QStringLiteral("back"))->trigger();
break;
case Qt::Key_Right:
d->m_ops->actionCollection()->action(QStringLiteral("forward"))->trigger();
break;
default:
break;
}
}
} else if (watched == d->m_ops && event->type() == QEvent::KeyPress &&
(keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter)) {
// ignore return events from the KDirOperator
// they are not needed, activated is used to handle this case
event->accept();
return true;
}
} else if (watched == d->m_ops && event->type() == QEvent::KeyPress &&
(keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter)) {
// ignore return events from the KDirOperator
// they are not needed, activated is used to handle this case
event->accept();
return true;
}
return res;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment