Skip to content

Commit 254bdf5

Browse files
XINJIANGMOmergify[bot]
authored andcommitted
Fix crash and synchronize gui when disabling gi with active debug visualization mode (#3062)
When gi is being disabled (Enabled changes from true to false), the code sets the debug visualization mode to None, marks it as dirty, and sets a flag. After releasing the mutex lock, if the flag is set, it emits the DebugVisualizationModeChanged signal to notify the GUI to update. This ensures internal state consistency and prevents crashes by forcing the debug visualization mode to None when gi is off. Emitting the signal outside the lock avoids deadlocks and keeps the GUI synchronized with the internal state. Signed-off-by: momo <[email protected]> (cherry picked from commit 42ab45a)
1 parent 47a2580 commit 254bdf5

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/gui/plugins/global_illumination_vct/GlobalIlluminationVct.cc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,23 @@ void GlobalIlluminationVct::UpdateOctantCount(int _axis, uint32_t _count)
549549
//////////////////////////////////////////////////
550550
void GlobalIlluminationVct::SetEnabled(const bool _enabled)
551551
{
552-
std::lock_guard<std::mutex> lock(this->dataPtr->serviceMutex);
553-
this->dataPtr->enabled = _enabled;
554-
this->dataPtr->visualDirty = true;
552+
bool needEmitDebugVisChanged = false;
553+
{
554+
std::lock_guard<std::mutex> lock(this->dataPtr->serviceMutex);
555+
if (this->dataPtr->enabled && !_enabled)
556+
{
557+
// When disabling GI, force debugVisMode to None for safety
558+
this->dataPtr->debugVisMode = rendering::GlobalIlluminationVct::DVM_None;
559+
this->dataPtr->debugVisualizationDirty = true;
560+
needEmitDebugVisChanged = true;
561+
}
562+
this->dataPtr->enabled = _enabled;
563+
this->dataPtr->visualDirty = true;
564+
}
565+
if (needEmitDebugVisChanged)
566+
{
567+
this->DebugVisualizationModeChanged();
568+
}
555569
}
556570

557571
//////////////////////////////////////////////////

0 commit comments

Comments
 (0)