Skip to content

Commit f852ed8

Browse files
committed
pdlua update
1 parent 0c21224 commit f852ed8

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

Libraries/pd-lua

Source/Objects/LuaObject.h

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct LuaPropertiesPanel
4242
auto atoms = pd::Atom::fromAtoms(argc, argv);
4343

4444
for (auto* propertiesPanel : allPropertiesTargets[static_cast<t_pdlua*>(target)]) {
45-
if (symbol == hash("add_frame_property") && atoms.size() >= 1)
45+
if (symbol == hash("add_frame_property") && atoms.size() >= 1 && propertiesPanel->object)
4646
{
4747
auto* frame = propertiesPanel->newFrame(atoms[0].toString());
4848
propertiesPanel->object->objectParameters.addParamCustom([object = propertiesPanel->object, frame]() -> PropertiesPanelProperty*
@@ -423,8 +423,8 @@ class LuaObject final : public ObjectBase
423423

424424
if (auto pdlua = _this->ptr.get<t_pd>()) {
425425
// Reload the lua script
426-
pd_typedmess(_this->pdluaxSymbol->s_thing, gensym("reload"), 0, nullptr);
427-
pd_typedmess(_this->pdluaxjitSymbol->s_thing, gensym("reload"), 0, nullptr);
426+
if(_this->pdluaxSymbol->s_thing) pd_typedmess(_this->pdluaxSymbol->s_thing, gensym("reload"), 0, nullptr);
427+
if(_this->pdluaxjitSymbol->s_thing) pd_typedmess(_this->pdluaxjitSymbol->s_thing, gensym("reload"), 0, nullptr);
428428

429429
// Recreate this object
430430
if (auto patch = _this->cnv->patch.getPointer()) {
@@ -972,11 +972,13 @@ class LuaObject final : public ObjectBase
972972
for(auto& guiMessage : layerMessages) {
973973
handleGuiMessage(nvg, layer, guiMessage.symbol, guiMessage.size, guiMessage.data.data());
974974
}
975-
976-
if (isSelected != object->isSelected() || !framebuffers[layer].isValid()) {
977-
isSelected = object->isSelected();
975+
if (!framebuffers[layer].isValid())
978976
sendRepaintMessage();
979-
}
977+
}
978+
979+
if (isSelected != object->isSelected()) {
980+
isSelected = object->isSelected();
981+
sendRepaintMessage();
980982
}
981983
}
982984

@@ -1060,8 +1062,8 @@ class LuaObject final : public ObjectBase
10601062
if (result == 2) {
10611063
fileToOpen.replaceWithText(newText);
10621064
if (auto pdlua = _this->ptr.get<t_pd>()) {
1063-
pd_typedmess(_this->pdluaxSymbol->s_thing, gensym("reload"), 0, nullptr);
1064-
pd_typedmess(_this->pdluaxjitSymbol->s_thing, gensym("reload"), 0, nullptr);
1065+
if(_this->pdluaxSymbol->s_thing) pd_typedmess(_this->pdluaxSymbol->s_thing, gensym("reload"), 0, nullptr);
1066+
if(_this->pdluaxjitSymbol->s_thing) pd_typedmess(_this->pdluaxjitSymbol->s_thing, gensym("reload"), 0, nullptr);
10651067
// Recreate this object
10661068
if (auto patch = _this->cnv->patch.getPointer()) {
10671069
pd::Interface::recreateTextObject(patch.get(), pdlua.cast<t_gobj>());
@@ -1085,8 +1087,8 @@ class LuaObject final : public ObjectBase
10851087

10861088
fileToOpen.replaceWithText(newText);
10871089
if (auto pdlua = ptr.get<t_pd>()) {
1088-
pd_typedmess(pdluaxSymbol->s_thing, gensym("reload"), 0, nullptr);
1089-
pd_typedmess(pdluaxjitSymbol->s_thing, gensym("reload"), 0, nullptr);
1090+
if(pdluaxSymbol->s_thing) pd_typedmess(pdluaxSymbol->s_thing, gensym("reload"), 0, nullptr);
1091+
if(pdluaxjitSymbol->s_thing) pd_typedmess(pdluaxjitSymbol->s_thing, gensym("reload"), 0, nullptr);
10901092
}
10911093
sendRepaintMessage();
10921094
};
@@ -1169,8 +1171,8 @@ class LuaTextObject final : public TextObjectBase {
11691171
return;
11701172
if (auto pdlua = _this->ptr.get<t_pd>()) {
11711173
// Reload the lua script
1172-
pd_typedmess(_this->pdluaxSymbol->s_thing, gensym("reload"), 0, nullptr);
1173-
pd_typedmess(_this->pdluaxjitSymbol->s_thing, gensym("reload"), 0, nullptr);
1174+
if(_this->pdluaxSymbol->s_thing) pd_typedmess(_this->pdluaxSymbol->s_thing, gensym("reload"), 0, nullptr);
1175+
if(_this->pdluaxjitSymbol->s_thing) pd_typedmess(_this->pdluaxjitSymbol->s_thing, gensym("reload"), 0, nullptr);
11741176

11751177
// Recreate this object
11761178
if (auto patch = _this->cnv->patch.getPointer()) {
@@ -1209,7 +1211,8 @@ class LuaTextObject final : public TextObjectBase {
12091211
if (result == 2) {
12101212
fileToOpen.replaceWithText(newText);
12111213
if (auto pdlua = ptr.get<t_pd>()) {
1212-
pd_typedmess(pdluaxSymbol->s_thing, gensym("reload"), 0, nullptr);
1214+
if(pdluaxSymbol->s_thing) pd_typedmess(pdluaxSymbol->s_thing, gensym("reload"), 0, nullptr);
1215+
if(pdluaxjitSymbol->s_thing) pd_typedmess(pdluaxjitSymbol->s_thing, gensym("reload"), 0, nullptr);
12131216
// Recreate this object
12141217
if (auto patch = cnv->patch.getPointer()) {
12151218
pd::Interface::recreateTextObject(patch.get(), pdlua.cast<t_gobj>());
@@ -1233,8 +1236,8 @@ class LuaTextObject final : public TextObjectBase {
12331236
fileToOpen.replaceWithText(newText);
12341237
if (auto pdlua = ptr.get<t_pd>()) {
12351238
if (pdluaxSymbol->s_thing) {
1236-
pd_typedmess(pdluaxSymbol->s_thing, gensym("reload"), 0, nullptr);
1237-
pd_typedmess(pdluaxjitSymbol->s_thing, gensym("reload"), 0, nullptr);
1239+
if(pdluaxSymbol->s_thing) pd_typedmess(pdluaxSymbol->s_thing, gensym("reload"), 0, nullptr);
1240+
if(pdluaxjitSymbol->s_thing) pd_typedmess(pdluaxjitSymbol->s_thing, gensym("reload"), 0, nullptr);
12381241
}
12391242
}
12401243
};

0 commit comments

Comments
 (0)