Skip to content

Commit ec5ebfd

Browse files
committed
fix crash when Code parameter is blank
1 parent 84caa2c commit ec5ebfd

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/ChucKDesignerCHOP.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,9 @@ extern "C"
471471
info->customOPInfo.authorName->setString("David Braun");
472472
info->customOPInfo.authorEmail->setString("github.com/DBraun");
473473

474+
info->customOPInfo.majorVersion = 0;
475+
info->customOPInfo.minorVersion = 3;
476+
474477
info->customOPInfo.minInputs = 0;
475478
info->customOPInfo.maxInputs = 1;
476479

@@ -556,6 +559,7 @@ ChucKDesignerCHOP::getChannelName(int32_t index, OP_String *name, const OP_Input
556559

557560
void
558561
ChucKDesignerCHOP::reset() {
562+
myError.str("");
559563
ChucK_For_TouchDesigner::clearGlobals(m_chuckID);
560564
ChucK_For_TouchDesigner::clearChuckInstance(m_chuckID);
561565
ChucK_For_TouchDesigner::cleanupChuckInstance(m_chuckID, myNodeInfo->opId);
@@ -578,11 +582,7 @@ ChucKDesignerCHOP::execute(CHOP_Output* output,
578582
if (needCompile) {
579583
needCompile = false;
580584

581-
// Until ChucK on windows parses the working directory better,
582-
// we have to pass it as a relative path rather than an absolute path.
583-
// https://github.com/ccrma/chuck/blob/de0530b4d0d85c9fe4abca17019730fe8e8e0454/src/core/chuck.cpp#L524
584-
string globalDir = inputs->getParString("Workingdirectory");
585-
//string globalDir = inputs->getParFilePath("Workingdirectory");
585+
string globalDir = inputs->getParFilePath("Workingdirectory");
586586

587587
double sample_rate = inputs->getParDouble("Samplerate");
588588

@@ -602,16 +602,18 @@ ChucKDesignerCHOP::execute(CHOP_Output* output,
602602

603603
ChucK_For_TouchDesigner::initChuckInstance(m_chuckID, sample_rate, m_inChannels, m_outChannels, globalDir);
604604

605-
const OP_DATInput* input = inputs->getParDAT("Code");
606-
const char* code = *(input->cellData);
605+
const OP_DATInput* codeInput = inputs->getParDAT("Code");
607606

608-
bool result = ChucK_For_TouchDesigner::runChuckCode(m_chuckID, code);
609-
if (result) {
610-
// clear any existing error
611-
myError.str("");
612-
}
613-
else {
614-
myError.str("ChucK code did not compile correctly.");
607+
myError.str("");
608+
609+
if (codeInput) {
610+
const char* code = *(codeInput->cellData);
611+
bool result = ChucK_For_TouchDesigner::runChuckCode(m_chuckID, code);
612+
if (!result) {
613+
myError.str("ChucK code did not compile correctly.");
614+
}
615+
} else {
616+
myError.str("You must specify ChucK Code.");
615617
}
616618
}
617619

0 commit comments

Comments
 (0)