From 246fa6c1fa496214f9f58717232751ff8c6f2fb5 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Fri, 25 Apr 2014 20:43:01 +0400 Subject: [PATCH] Fix rare and strange crash in modern UI --- wordlist.cc | 17 +++++++++++++++++ wordlist.hh | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/wordlist.cc b/wordlist.cc index 25a44224..43e2e5c4 100644 --- a/wordlist.cc +++ b/wordlist.cc @@ -137,3 +137,20 @@ void WordList::refreshTranslateLine() } } + +void WordList::resizeEvent( QResizeEvent * ev ) +{ + // In some rare cases Qt start send QResizeEvent recursively + // up to full stack depletion (tested on Qt 4.8.5, 4.8.6). + // We use this trick to break such suicidal process. + + for( int x = 0; x < resizedSizes.size(); x++ ) + if( resizedSizes.at( x ) == ev->size() ) + return; + + resizedSizes.push_back( ev->size() ); + + QListWidget::resizeEvent( ev ); + + resizedSizes.pop_back(); +} diff --git a/wordlist.hh b/wordlist.hh index c603105a..71b0131f 100644 --- a/wordlist.hh +++ b/wordlist.hh @@ -19,6 +19,9 @@ public: virtual void setTranslateLine(QLineEdit * line) { translateLine = line; } +protected: + virtual void resizeEvent( QResizeEvent * ev ); + signals: void statusBarMessage(QString const & message, int timeout = 0, QPixmap const & pixmap = QPixmap()); void contentChanged(); @@ -36,6 +39,8 @@ private: WordFinder * wordFinder; QLineEdit * translateLine; WordListItemDelegate listItemDelegate; + + QVector< QSize > resizedSizes; }; #endif // WORDLIST_HH