Mercurial > octave
diff libgui/src/main-window.cc @ 19425:5e93d228ff6b gui-release
fix regression from 476032040df9 (endless loop while looking for active widget)
* main_window.cc (focus_changed): store start widget before looping through
the focus change since previousInFocusChain does not return 0 at the
beginning of the chain; moreover quit looking for active dock after 100 times
author | Torsten <ttl@justmail.de> |
---|---|
date | Wed, 24 Dec 2014 13:58:00 +0100 |
parents | 476032040df9 |
children | f90bb1e30de2 |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Tue Dec 23 16:29:02 2014 +0100 +++ b/libgui/src/main-window.cc Wed Dec 24 13:58:00 2014 +0100 @@ -161,15 +161,24 @@ // catch focus changes and determine the active dock widget void -main_window::focus_changed (QWidget *, QWidget *w_new) +main_window::focus_changed (QWidget *, QWidget *new_widget) { octave_dock_widget* dock = 0; - while (w_new && w_new != _main_tool_bar) + QWidget *w_new = new_widget; // get a copy of new focus widget + QWidget *start = w_new; // Save it as start of our search + int count = 0; // fallback to prevent endless loop + + while (w_new && w_new != _main_tool_bar && count < 100) { dock = qobject_cast <octave_dock_widget *> (w_new); if (dock) - break; // its a QDockWidget + break; // it is a QDockWidget ==> exit loop + w_new = qobject_cast <QWidget *> (w_new->previousInFocusChain ()); + if (w_new == start) + break; // we have arrived where we began ==> exit loop + + count++; } // if new dock has focus, emit signal and store active focus