Skip to content

Commit 8cc02d5

Browse files
committed
Fixed Invalid UI Calls
1 parent 469e105 commit 8cc02d5

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

Plateau2/Plateau2.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,6 @@ Plateau2::Plateau2(const InstanceInfo& info)
237237

238238
pGraphics->AttachControl(tank1Select);
239239
pGraphics->AttachControl(tank2Select);
240-
241-
initalizedInterface = true;
242240
};
243241
#endif
244242
}
@@ -320,20 +318,24 @@ void Plateau2::UpdateSendVisibility() {
320318
SVGs[4]->Hide(currentPage != 2 || (!dangerous && tank2Selected));
321319
}
322320

321+
bool Plateau2::WindowIsOpen() {
322+
IGraphics* pGraphics = GetUI();
323+
return pGraphics && pGraphics->WindowIsOpen();
324+
}
323325

324326
void Plateau2::OnParamChange(int index)
325327
{
326328
switch (index) {
327329
case kClear:
328-
if (initalizedInterface) {
330+
if (WindowIsOpen()) {
329331
if (GetParam(kClear)->Value() >= 0.5) {
330332
SetParameterValue(kClear1, GetParam(kClear)->Value());
331333
SetParameterValue(kClear2, GetParam(kClear)->Value());
332334
}
333335
}
334336
break;
335337
case kFreeze:
336-
if (initalizedInterface)
338+
if (WindowIsOpen())
337339
{
338340
if (GetParam(kFreeze)->Value() >= 0.5) {
339341
SetParameterValue(tank2Selected ? kFreeze1 : kFreeze2, 1.);
@@ -510,11 +512,11 @@ void Plateau2::OnParamChange(int index)
510512
break;
511513

512514
case kDanger:
513-
if (!GetParam(kDanger)->Value()) {
515+
if (GetParam(kDanger)->Value()<=0.5) {
514516
//Reset the plugin when danger is turned off for safety
515517
SetParameterValue(kClear, 1);
516518
}
517-
if (initalizedInterface) {
519+
if (WindowIsOpen()) {
518520
UpdateSendVisibility();
519521
Knobs[13]->Bound = GetParam(kDanger)->Value() ? 135.f : 72.6923f;
520522

Plateau2/Plateau2.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,13 @@ class Plateau2 final : public Plugin
9797
{
9898
public:
9999
Plateau2(const InstanceInfo& info);
100-
101-
bool initalizedInterface = false;
102-
103-
104100
#if IPLUG_DSP // http://bit.ly/2S64BDd
105101
void ProcessBlock(sample** inputs, sample** outputs, int nFrames) override;
106102
void ChangePage(int direction, const ISVG PageBackgrounds[kNumPages], const ISVG NextButtons[kNumPages], const ISVG PreviousButtons[kNumPages]);
107103
void UpdatePageVisibility();
108104
void UpdateSendVisibility();
109105
void OnParamChange(int index) override;
106+
bool Plateau2::WindowIsOpen();
110107
void SelectTank(bool tank2);
111108
#endif
112109
private:

0 commit comments

Comments
 (0)