Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] ContextHandler: Merge local context into globals before serialization #2837

Merged
merged 1 commit into from
Dec 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions Orange/widgets/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,20 +650,21 @@ def pack_data(self, widget):
return data

def update_defaults(self, widget):
"""Call the inherited method, then merge the local context into the
global contexts. This make sense only when the widget does not use
global context (i.e. `widget.context_settings is not
self.global_contexts`); this happens when the widget was initialized by
an instance-specific data that was passed to :obj:`initialize`."""
"""
Reimplemented from SettingsHandler

Merge the widgets local contexts into the global contexts and persist
the settings (including the contexts) to disk.
"""
self.settings_from_widget(widget)
globs = self.global_contexts
assert widget.context_settings is not globs
ids = {id(c) for c in globs}
globs += (c for c in widget.context_settings if id(c) not in ids)
globs.sort(key=lambda c: -c.time)
del globs[self.MAX_SAVED_CONTEXTS:]

super().update_defaults(widget)
globs = self.global_contexts
if widget.context_settings is not globs:
ids = {id(c) for c in globs}
globs += (c for c in widget.context_settings if id(c) not in ids)
globs.sort(key=lambda c: -c.time)
del globs[self.MAX_SAVED_CONTEXTS:]

def new_context(self, *args):
"""Create a new context."""
Expand Down