# HG changeset patch # User Torsten # Date 1419425880 -3600 # Node ID 5e93d228ff6b3e3a9e636f2e56dbb7588195d1cd # Parent d93293218966f45b8fbeb294621e9a6c61c985a8 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 diff -r d93293218966 -r 5e93d228ff6b libgui/src/main-window.cc --- 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 (w_new); if (dock) - break; // its a QDockWidget + break; // it is a QDockWidget ==> exit loop + w_new = qobject_cast (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