Skip to content

Addressing issue #165, dictionary changes size during iteration - #166

Merged
dirk-thomas merged 2 commits into
crystal-develfrom
issue_165
Jan 12, 2019
Merged

dirk-thomas merged 2 commits into
crystal-develfrom
issue_165

Conversation

@brawner

@brawner brawner commented Jan 3, 2019 •

Copy link
Copy Markdown
Contributor

This PR creates a shallow copy of the values from the dictionary that may change sizes during iteration.

Addresses issue #165

@ghost ghost assigned brawner Jan 3, 2019
@ghost ghost added the in progress label Jan 3, 2019

@mlautman mlautman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find!

@dirk-thomas

Copy link
Copy Markdown
Contributor

Can you please point to the case where _save_plugin_settings changes the _running_plugins.

@brawner

brawner commented Jan 12, 2019

Copy link
Copy Markdown
Contributor Author

That happens here as mentioned in issue #165.

self._running_plugins.pop(str(instance_id))

@dirk-thomas

dirk-thomas commented Jan 12, 2019 •

Copy link
Copy Markdown
Contributor

That call is in _remove_running_plugin - not in _save_plugin_settings?

Maybe you can post the full stacktrace from the loop iterating over the collection to the pop call modifying the collections.

@brawner

brawner commented Jan 12, 2019

Copy link
Copy Markdown
Contributor Author

True, but it calls callback, which I've had a lot of trouble tracking down what function that is. The above location is the only place in the file where items are removed from that dictionary that I can find.

callback(instance_id)

@brawner

brawner commented Jan 12, 2019

Copy link
Copy Markdown
Contributor Author

For instance, does it lead to _restore_settings_restore_callback which just ends up emitting another signal?

self.plugins_changed_signal.emit()

@dirk-thomas
dirk-thomas merged commit 3b01b7f into crystal-devel Jan 12, 2019
@ghost ghost removed the in progress label Jan 12, 2019
@dirk-thomas
dirk-thomas deleted the issue_165 branch January 12, 2019 02:11
@dirk-thomas

Copy link
Copy Markdown
Contributor

It looks like the same patch should be applied to the ROS 1 branch too. Please either cherry-pick the commit to the default branch or create a separate PR for it. Thanks.

@brawner

brawner commented Jan 12, 2019

Copy link
Copy Markdown
Contributor Author

Full traceback just before self._running_plugins.pop(str(instance_id))

File "/Users/brawner/workspace/ros2_ws/install/rqt_gui/bin/rqt", line 11, in <module>
    load_entry_point('rqt-gui==1.0.0', 'console_scripts', 'rqt')()
File "/Users/brawner/workspace/ros2_ws/install/rqt_gui/lib/python3.7/site-packages/rqt_gui/main.py", line 87, in main
    sys.exit(Main().main())
File "/Users/brawner/workspace/ros2_ws/install/rqt_gui/lib/python3.7/site-packages/rqt_gui/main.py", line 59, in main
    plugin_argument_provider=plugin_argument_provider)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/main.py", line 646, in main
    return app.exec_()
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/perspective_manager.py", line 145, in switch_perspective
    self.save_settings_signal.emit(self._global_settings, self._perspective_settings)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_manager.py", line 420, in save_settings
    self._save_settings(global_settings, perspective_settings, self._save_settings_callback)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_manager.py", line 434, in _save_settings
    self._save_plugin_settings(info['instance_id'], callback)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_manager.py", line 341, in _save_plugin_settings
    handler.save_settings(plugin_settings, instance_settings, callback)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_handler.py", line 191, in save_settings
    self._save_settings(plugin_settings, instance_settings)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_handler_direct.py", line 114, in _save_settings
    self.emit_save_settings_completed()
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_handler.py", line 207, in emit_save_settings_completed
    callback(self._instance_id)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_manager.py", line 455, in _save_settings_callback
    self.save_settings_completed_signal.emit()
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/perspective_manager.py", line 188, in save_settings_completed
    callback(*callback_args)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/perspective_manager.py", line 177, in _switch_perspective
    self._global_settings, self._perspective_settings)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_manager.py", line 492, in restore_settings
    self._restore_settings_save_obsolete()
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_manager.py", line 506, in _restore_settings_save_obsolete
    self._shutdown_plugin(instance_id, self._restore_settings_unload_obsolete)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_manager.py", line 354, in _shutdown_plugin
    handler.shutdown_plugin(callback)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_handler_direct.py", line 80, in shutdown_plugin
    super(PluginHandlerDirect, self).shutdown_plugin(callback)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_handler.py", line 136, in shutdown_plugin
    self._shutdown_plugin()
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_handler_direct.py", line 92, in _shutdown_plugin
    self.emit_shutdown_plugin_completed()
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_handler.py", line 150, in emit_shutdown_plugin_completed
    callback(self._instance_id)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_manager.py", line 522, in _restore_settings_unload_obsolete
    self._unload_plugin(instance_id, self._restore_settings_unload_obsolete_callback)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_manager.py", line 364, in _unload_plugin
    handler.unload(callback)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_handler.py", line 166, in unload
    self._unload()
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_handler_direct.py", line 102, in _unload
    self._emit_unload_completed()
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_handler.py", line 179, in _emit_unload_completed
    callback(self._instance_id)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_manager.py", line 527, in _restore_settings_unload_obsolete_callback
    self._remove_running_plugin(instance_id)
File "/Users/brawner/workspace/ros2_ws/install/qt_gui/lib/python3.7/site-packages/qt_gui/plugin_manager.py", line 377, in _remove_running_plugin
    for line in traceback.format_stack():

brawner added a commit that referenced this pull request Jan 12, 2019
* Addressing issue #165, dictionary changes size during iteration

* remove single use temporary variable
brawner added a commit that referenced this pull request Jan 12, 2019
#167)

* Addressing issue #165, dictionary changes size during iteration

* remove single use temporary variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants