Skip to content

Commit 45958ac

Browse files
committed
Duct tape over some JS error getting when loading batch GUI under some conditions.
Some how JS loading of spectrum chart was getting out of sync with load thier parent divs - I hypothesize; added in some delays, and so dont seem to be seeing it any more. Also, disabled D3SpectrumDisplayDiv from removeing its style rules at destruct, because this was effecting other charts
1 parent e92631e commit 45958ac

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

src/BatchGuiInputFile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ BatchGuiInputSpectrumFile::BatchGuiInputSpectrumFile( const std::string display_
194194
*status_ptr = is_csv ? 2 : 3;
195195
}// if( parsed as spectrum file ) / else
196196

197-
WServer::instance()->post( sessionid, updateGuiCallback );
197+
WServer::instance()->schedule( 250, sessionid, updateGuiCallback );
198198
} );
199199
}// BatchGuiInputSpectrumFile constructor
200200

@@ -299,7 +299,7 @@ void BatchGuiInputSpectrumFile::set_spectrum( std::shared_ptr<SpecMeas> spec_mea
299299
spec->resize( WLength( 100, WLength::Percentage ), WLength( 100, WLength::Percentage ) );
300300

301301
// We dont currently need to explicitly set the color theme, as all color theme styling for
302-
// D3SpectrumDisplayDiv is globablly applied...
302+
// D3SpectrumDisplayDiv is globally applied...
303303
// InterSpec *interspec = InterSpec::instance();
304304
// spec->applyColorTheme( interspec->getColorTheme() );
305305
// interspec->colorThemeChanged().connect( boost::bind( &D3SpectrumDisplayDiv::applyColorTheme, spec,

src/BatchGuiWidget.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
2828
#include <chrono>
2929

3030
#include <Wt/WMenu>
31+
#include <Wt/WServer>
3132
#include <Wt/WGroupBox>
3233
#include <Wt/WGridLayout>
3334
#include <Wt/WPushButton>
3435
#include <Wt/WApplication>
3536
#include <Wt/WStackedWidget>
3637
#include <Wt/WContainerWidget>
3738

39+
#include "SpecUtils/Filesystem.h"
3840

3941
#include "InterSpec/SpecMeas.h"
4042
#include "InterSpec/InterSpec.h"
@@ -214,7 +216,35 @@ BatchGuiWidget::BatchGuiWidget( FileDragUploadResource *uploadResource, Wt::WCon
214216
m_input_status_error->addStyleClass( "ReasonCantAnalyzeMsg" );
215217
m_input_status_error->hide();
216218

217-
addInputFiles( m_uploadResource->takeSpooledFiles() );
219+
220+
const vector<tuple<string,string,bool>> spooled_files = m_uploadResource->takeSpooledFiles();
221+
222+
// We will load the initial spectrum files, after giving the widget a second to fully load.
223+
// I'm not quite sure why, but without doing this, sometimes we can get a JS exception,
224+
// maybe because the JS is somehow getting out of order?
225+
//addInputFiles( m_uploadResource->takeSpooledFiles() );
226+
227+
boost::function<void()> load_files
228+
= wApp->bind( boost::bind( &BatchGuiWidget::addInputFiles, this, spooled_files ) );
229+
boost::function<void()> worker = [load_files](){
230+
load_files();
231+
wApp->triggerUpdate();
232+
};
233+
234+
// Fallback function to clean the files up, incase this session is no longer alive
235+
// BUT note that there is a path where if this widget is deleted, before the worker is called,
236+
// then the files wont be cleaned up any way.
237+
boost::function<void()> fall_back = [spooled_files](){
238+
for( const tuple<string, string, bool> &file : spooled_files )
239+
{
240+
const string &path_to_file = std::get<1>( file );
241+
const bool should_delete = std::get<2>( file );
242+
if( should_delete )
243+
SpecUtils::remove_file( path_to_file );
244+
}
245+
};//fall_back
246+
247+
WServer::instance()->schedule( 500, wApp->sessionId(), worker, fall_back );
218248
}// BatchGuiWidget constructor
219249

220250
BatchGuiWidget::~BatchGuiWidget()

src/D3SpectrumDisplayDiv.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2878,8 +2878,9 @@ D3SpectrumDisplayDiv::~D3SpectrumDisplayDiv()
28782878
WCssStyleSheet &style = wApp->styleSheet();
28792879
for( const auto name_rule : m_cssRules )
28802880
{
2881-
if( !name_rule.first.empty() && style.isDefined(name_rule.first) )
2882-
style.removeRule( name_rule.second );
2881+
cout << "Not remove style rule '" << name_rule.first << "' since it messes things up - need to implement applying chart rules globally, instead of for each instance." << endl;
2882+
//if( !name_rule.first.empty() && style.isDefined(name_rule.first) )
2883+
// style.removeRule( name_rule.second );
28832884
}
28842885
}//~D3SpectrumDisplayDiv()
28852886

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
</dict>
8+
</plist>

0 commit comments

Comments
 (0)