Nicer fix for mac crash.

This commit is contained in:
John Maguire 2010-12-21 14:55:42 +00:00
parent a139d46114
commit 596b5471b1
2 changed files with 12 additions and 2 deletions

View File

@ -30,7 +30,8 @@ PrettyImageView::PrettyImageView(QWidget* parent)
container_(new QWidget(this)),
layout_(new QHBoxLayout(container_)),
current_index_(-1),
scroll_animation_(new QPropertyAnimation(horizontalScrollBar(), "value", this))
scroll_animation_(new QPropertyAnimation(horizontalScrollBar(), "value", this)),
recursion_filter_(false)
{
setWidget(container_);
setWidgetResizable(true);
@ -54,7 +55,14 @@ PrettyImageView::PrettyImageView(QWidget* parent)
}
bool PrettyImageView::eventFilter(QObject* obj, QEvent* event) {
return false;
// Work around infinite recursion in QScrollArea resizes.
if (recursion_filter_) {
return false;
}
recursion_filter_ = true;
bool ret = QScrollArea::eventFilter(obj, event);
recursion_filter_ = false;
return ret;
}
void PrettyImageView::AddImage(const QUrl& url) {

View File

@ -57,6 +57,8 @@ private:
int current_index_;
QPropertyAnimation* scroll_animation_;
bool recursion_filter_;
};
#endif // PRETTYIMAGEVIEW_H