Skip to content

Commit

Permalink
Attempt to fix some crashes, but finding the actual underlying trigge…
Browse files Browse the repository at this point in the history
…r is going to be difficult.
  • Loading branch information
dkulp committed Nov 4, 2023
1 parent 44215fe commit 2f8d09e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions xLights/LayoutPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ void LayoutPanel::OnPropertyGridChange(wxPropertyGridEvent& event) {
}
else {
if (editing_models) {
xlights->AbortRender();
if (selectedBaseObject != nullptr) {
Model* selectedModel = dynamic_cast<Model*>(selectedBaseObject);
//model property
Expand Down Expand Up @@ -946,6 +947,7 @@ void LayoutPanel::OnPropertyGridChanging(wxPropertyGridEvent& event) {
xlights->AddTraceMessage("LayoutPanel::OnPropertyGridChanging Property: " + name);
if (selectedBaseObject != nullptr) {
if( editing_models ) {
xlights->AbortRender();
Model* selectedModel = dynamic_cast<Model*>(selectedBaseObject);
if ("ModelName" == name) {
std::string safename = Model::SafeModelName(event.GetValue().GetString().ToStdString());
Expand Down
8 changes: 7 additions & 1 deletion xLights/models/ModelGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,6 @@ bool ModelGroup::SubModelRenamed(const std::string &oldName, const std::string &
}

bool ModelGroup::CheckForChanges() const {

unsigned long l = 0;
for (const auto& it : models) {
ModelGroup *grp = dynamic_cast<ModelGroup*>(it);
Expand All @@ -875,6 +874,13 @@ bool ModelGroup::CheckForChanges() const {
}

if (l != changeCount) {
if (!wxThread::IsMain()) {
//calling reset on any thread other than the main thread is bad. In theory, any changes to the group/model
//would only be done on the main thread after an abortRender call so we shouldn't get here, but we are
//seeing stack traces in crash reports that show otherwise so likely some abortRender calls are missing.
return false;
}

// this is ugly ... it is casting away the const-ness of this
ModelGroup *group = (ModelGroup*)this;
if (group != nullptr) group->Reset();
Expand Down

0 comments on commit 2f8d09e

Please sign in to comment.