diff options
author | Richard Antalik <richardantalik@gmail.com> | 2021-05-25 16:02:31 +0300 |
---|---|---|
committer | Richard Antalik <richardantalik@gmail.com> | 2021-05-25 16:08:32 +0300 |
commit | 0f7becece7fd829f8ccb9c0fdcb5b929fc25fb70 (patch) | |
tree | 4b2d4b1f2d00de97f9033b8d1a7daefcfa2273fa /source/blender/sequencer/intern | |
parent | 1a69d491e57cb7b7a834f265f59df3bd8f01e55b (diff) |
Fix T88551: Crash accessing uninitialized tool settings
Tool settings for sequencer were not initialized, which caused crash
when adding strips.
There was fix for same issue in versioning rB0f81dafe6cec, but
subversion was not bumped, so files with uninitialized tool settings
may still exist.
Add `SEQ_tool_settings_get()` accessor function that will initialize
tool settings if they are missing. Change operator code to use
`SEQ_tool_settings_fit_method_get()` function instead of accessing
tool settings directly
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D11383
Diffstat (limited to 'source/blender/sequencer/intern')
-rw-r--r-- | source/blender/sequencer/intern/sequencer.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/sequencer/intern/sequencer.c b/source/blender/sequencer/intern/sequencer.c index cc11796496c..b00c36ad8e4 100644 --- a/source/blender/sequencer/intern/sequencer.c +++ b/source/blender/sequencer/intern/sequencer.c @@ -313,6 +313,17 @@ SequencerToolSettings *SEQ_tool_settings_init(void) return tool_settings; } +SequencerToolSettings *SEQ_tool_settings_ensure(Scene *scene) +{ + SequencerToolSettings *tool_settings = scene->toolsettings->sequencer_tool_settings; + if (tool_settings == NULL) { + scene->toolsettings->sequencer_tool_settings = SEQ_tool_settings_init(); + tool_settings = scene->toolsettings->sequencer_tool_settings; + } + + return tool_settings; +} + void SEQ_tool_settings_free(SequencerToolSettings *tool_settings) { MEM_freeN(tool_settings); @@ -320,13 +331,13 @@ void SEQ_tool_settings_free(SequencerToolSettings *tool_settings) eSeqImageFitMethod SEQ_tool_settings_fit_method_get(Scene *scene) { - const SequencerToolSettings *tool_settings = scene->toolsettings->sequencer_tool_settings; + const SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene); return tool_settings->fit_method; } void SEQ_tool_settings_fit_method_set(Scene *scene, eSeqImageFitMethod fit_method) { - SequencerToolSettings *tool_settings = scene->toolsettings->sequencer_tool_settings; + SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene); tool_settings->fit_method = fit_method; } |