Skip to content

Commit

Permalink
Sail - possible fix for crash #358
Browse files Browse the repository at this point in the history
  • Loading branch information
stoermelder committed Jan 21, 2023
1 parent d886e87 commit 9937f0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
- Fixed crash on exiting Rack's after adding MB (#352)
- Module [TRANSIT](./docs/Transit.md)
- Allow disabling of "long-press" for changing the number of active snapshots (#354)
- Module [SAIL](./docs/Sail.md)
- Fixed occasional crash (#358)

## 2.0.beta3

Expand Down
13 changes: 6 additions & 7 deletions src/Sail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ struct SailModule : Module {
float valueBaseOut;
float valuePrevious;

bool hoveredWidgetNull = true;
WeakPtr<ParamWidget> hoveredWidget;
int64_t hoveredModuleId = -1;
int hoveredParamId = -1;
Expand Down Expand Up @@ -111,11 +110,12 @@ struct SailModule : Module {
incdecTarget -= step;
}

ParamWidget* _hoveredWidget = hoveredWidget.get();
ParamQuantity* paramQuantity = NULL;
// paramQuantity is guaranteed to be existing after this point as we are in the middle of a sample
if (!hoveredWidgetNull && hoveredWidget.get() != nullptr) {
paramQuantity = hoveredWidget->getParamQuantity();
if (_hoveredWidget != nullptr) {
paramQuantity = _hoveredWidget->getParamQuantity();
}
// paramQuantity is guaranteed to be existing after this point as we are in the middle of a sample

if (processDivider.process() && paramQuantity && paramQuantity->module != this) {
if (paramQuantity->module->id != hoveredModuleId || paramQuantity->paramId != hoveredParamId) {
Expand Down Expand Up @@ -208,13 +208,12 @@ struct SailModule : Module {

void setHoveredWidget(ParamWidget* pw) {
if (pw) {
hoveredWidgetNull = false;
if (hoveredModuleId != pw->module->id || hoveredParamId != pw->paramId) {
hoveredWidget = pw;
}
}
else {
hoveredWidgetNull = true;
hoveredWidget.set(nullptr);
hoveredModuleId = -1;
hoveredParamId = -1;
}
Expand Down Expand Up @@ -290,7 +289,7 @@ struct SailWidget : ThemedModuleWidget<SailModule>, OverlayMessageProvider {
}

void getOverlayMessage(int id, Message& m) override {
if (module->hoveredWidgetNull || module->overlayMessageId != id) return;
if (module->hoveredWidget.get() == nullptr || module->overlayMessageId != id) return;
ParamWidget* pw = module->hoveredWidget.get();
if (pw == nullptr) return;
ParamQuantity* paramQuantity = pw->getParamQuantity();
Expand Down

0 comments on commit 9937f0a

Please sign in to comment.