Skip to content

Commit

Permalink
Remove null pointer checks when the pointer had already been used. Th… (
Browse files Browse the repository at this point in the history
#7852)

* Remove null pointer checks when the pointer had already been used. The code would have caused a crash before the null pointer test if it'd ever occur, so presumably it doesn't.

* Correct a static analyzer result

* more storage checks downstream

---------

Co-authored-by: David Lowndes <David@DAVIDPCZ>
Co-authored-by: Paul Walker <paul@pwjw.com>
  • Loading branch information
3 people authored Nov 22, 2024
1 parent 249e297 commit ad9d5f3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
20 changes: 16 additions & 4 deletions src/common/PatchDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,10 @@ CREATE TABLE IF NOT EXISTS Favorites (
}
catch (const SQL::Exception &e)
{
storage->reportError(e.what(), "PatchDB - Load Check");
if (storage)
{
storage->reportError(e.what(), "PatchDB - Load Check");
}
return;
}

Expand Down Expand Up @@ -832,7 +835,10 @@ CREATE TABLE IF NOT EXISTS Favorites (
}
catch (const SQL::Exception &e)
{
storage->reportError(e.what(), "PatchDB - Insert Patch");
if (storage)
{
storage->reportError(e.what(), "PatchDB - Insert Patch");
}
return;
}

Expand Down Expand Up @@ -934,7 +940,10 @@ CREATE TABLE IF NOT EXISTS Favorites (
}
catch (const SQL::Exception &e)
{
storage->reportError(e.what(), "PatchDB - FXP Features");
if (storage)
{
storage->reportError(e.what(), "PatchDB - FXP Features");
}
return;
}

Expand All @@ -950,7 +959,10 @@ CREATE TABLE IF NOT EXISTS Favorites (
}
catch (const SQL::Exception &e)
{
storage->reportError(e.what(), "PatchDB - FXP Features");
if (storage)
{
storage->reportError(e.what(), "PatchDB - FXP Features");
}
return;
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/common/SurgeStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1332,11 +1332,6 @@ void SurgeStorage::load_wt(int id, Wavetable *wt, OscillatorStorage *osc)
return;
}

if (!wt)
{
return;
}

load_wt(path_to_string(wt_list[id].path), wt, osc);

if (osc)
Expand Down
4 changes: 2 additions & 2 deletions src/surge-xt/gui/overlays/LuaEditors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ struct ExpandingFormulaDebugger : public juce::Component, public Surge::GUI::Ski

stepLfoDebugger();

if (editor && editor->editor)
if (editor->editor)
editor->editor->enqueueAccessibleAnnouncement("Reset Debugger");
}

Expand Down Expand Up @@ -339,7 +339,7 @@ struct ExpandingFormulaDebugger : public juce::Component, public Surge::GUI::Ski
debugTable->repaint();
}

if (editor && editor->editor)
if (editor->editor)
editor->editor->enqueueAccessibleAnnouncement("Stepped Debugger");
}

Expand Down
18 changes: 6 additions & 12 deletions src/surge-xt/gui/overlays/MSEGEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2943,14 +2943,11 @@ void MSEGControlRegion::valueChanged(Surge::GUI::IComponentTagValue *p)
Surge::MSEG::modifyEditMode(this->ms, editMode);

// zoom to fit
if (canvas)
{
canvas->ms->axisStart = 0.f;
canvas->ms->axisWidth = editMode ? 1.f : ms->envelopeModeDuration;
canvas->ms->axisStart = 0.f;
canvas->ms->axisWidth = editMode ? 1.f : ms->envelopeModeDuration;

canvas->modelChanged(0, false);
canvas->repaint();
}
canvas->modelChanged(0, false);
canvas->repaint();

repaint();
break;
Expand All @@ -2961,11 +2958,8 @@ void MSEGControlRegion::valueChanged(Surge::GUI::IComponentTagValue *p)
canvas->pushToUndo();
int m = floor((val * 2) + 0.1) + 1;
ms->loopMode = (MSEGStorage::LoopMode)m;
if (canvas)
{
canvas->modelChanged();
canvas->repaint();
}
canvas->modelChanged();
canvas->repaint();
repaint();
break;
}
Expand Down

0 comments on commit ad9d5f3

Please sign in to comment.