Skip to content

Commit 0d1b823

Browse files
committed
Work around bizarre bug in WebKit.
Sometimes when going to "Make Detector Response" tool, particularly the second time in a session, the Safari or Chrome rendering process would crash, after allocating lots of memory. This works around this, but its almost unbelievable, so there must be something else going on I don't understand, or perhaps this is just a patch for the one reproducible test case I was using.
1 parent f5ed41b commit 0d1b823

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/MakeDrf.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ namespace
455455
m_useForEffCb = new WCheckBox( "Use", this );
456456
m_useForEffCb->addStyleClass( "DrfPeakUseCb" );
457457

458-
char buffer[512];
458+
char buffer[256];
459459
if( peak && peak->parentNuclide() && peak->nuclearTransition() )
460460
{
461461
const bool use = peak->useForDrfIntrinsicEffFit();
@@ -508,6 +508,15 @@ namespace
508508
}
509509

510510
m_descTxt = new WText( WString::fromUTF8(buffer), this );
511+
// This is totally bizarre, but Safari (version 16.5 at least), and Chrome, will crash
512+
// (the rendering process for the tab, by running up huge amounts of memory), the
513+
// second time we create the "Make Detector Response" window, under some
514+
// circumstances (seems to happen most reliably with multiple spectrum files open
515+
// with lots of peaks). If we either limit the text length of `m_descTxt`, or
516+
// explicitly set its width to be less than 100%, then this crash doesnt happen.
517+
// Again, totally bizarre, and took quiet a while to pin down.
518+
// Perhaps there is something else going on??? Has to be, right?
519+
m_descTxt->setWidth( WLength(80,WLength::Percentage) );
511520
m_descTxt->addStyleClass( "DrfPeakInfoTxt" );
512521
m_backSubTxt = new WText( "", this );
513522
m_backSubTxt->addStyleClass( "DrfPeakBackSubTxt" );
@@ -2439,6 +2448,8 @@ void MakeDrf::handleSourcesUpdates()
24392448

24402449
fitEffEqn( effpoints );
24412450
fitFwhmEqn( peaks, highres );
2451+
2452+
wApp->triggerUpdate();
24422453
}//void handleSourcesUpdates()
24432454

24442455

@@ -3043,8 +3054,8 @@ void MakeDrf::writeCsvSummary( std::ostream &out,
30433054

30443055
const vector<MakeDrfChart::DataPoint> data = m_chart->currentDataPoints();
30453056

3046-
const int effDof = static_cast<int>(data.size()) - effEqnCoefs.size();
3047-
const int fwhmDof = static_cast<int>(data.size()) - fwhmCoefs.size();
3057+
const int effDof = static_cast<int>(data.size()) - static_cast<int>(effEqnCoefs.size());
3058+
const int fwhmDof = static_cast<int>(data.size()) - static_cast<int>(fwhmCoefs.size());
30483059

30493060
const bool effInMeV = isEffEqnInMeV();
30503061
const auto resFcnForm = DetectorPeakResponse::ResolutionFnctForm( m_fwhmEqnType->currentIndex() );

0 commit comments

Comments
 (0)