They're actual crashes (win32 exceptions in the operator log). I'm not sure exactly how much I should post but here are the relevant things:
Header file:
Code: Select all
#ifndef BALLOON_TASK_H
#define BALLOON_TASK_H
#include "FeedbackTask.h"
#include "TrialStatistics.h"
class BalloonTask : public FeedbackTask
{
public:
BalloonTask();
virtual ~BalloonTask();
private:
// Events to be handled by FeedbackTask descendants.
// Events triggered by the GenericFilter interface
virtual void OnPreflight( const SignalProperties& Input ) const;
virtual void OnInitialize( const SignalProperties& Input );
virtual void OnStartRun();
virtual void OnStopRun();
virtual void OnHalt();
// Events triggered during the course of a trial
virtual void OnTrialBegin();
virtual void OnTrialEnd();
virtual void OnFeedbackBegin();
virtual void OnFeedbackEnd();
// Dispatching of the input signal.
// Each call to GenericSignal::Process() is dispatched to one of these
// events, depending on the phase in the sequence.
// There, each handler function corresponds to a phase.
// If a handler sets the "progress" argument to true, the application's
// state will switch to the next phase.
virtual void DoPreRun( const GenericSignal&, bool& doProgress );
virtual void DoPreFeedback( const GenericSignal&, bool& doProgress );
virtual void DoFeedback( const GenericSignal&, bool& doProgress );
virtual void DoPostFeedback( const GenericSignal&, bool& doProgress );
virtual void DoITI( const GenericSignal&, bool& doProgress );
void SetLabel(const char* text, RGBColor &color);
template <class T>
void ShuffleList(int times, T list[]);
private:
int mRunCount,
mTrialCount;
float mCursorPosX,
mCursorPosY,
mCursorSpeedX,
mCursorSpeedY;
TrialStatistics mTrialStatistics;
class QWidget* mpForm;
class QGraphicsScene* mpScene;
class QGraphicsView* mpSceneView;
class QGraphicsTextItem* mpLabel;
class QGraphicsRectItem* mpTarget;
class QGraphicsEllipseItem* mpCursor;
};
#endif // BALLOON_TASK_H
The constructor for BalloonTask:
Code: Select all
BalloonTask::BalloonTask()
: mRunCount( 0 ),
mTrialCount( 0 ),
mCursorPosX( 0.0 ),
mCursorPosY( 0.0 ),
mCursorSpeedX( 0.0 ),
mCursorSpeedY( 0.0 ),
mpForm( new QWidget() ),
mpScene( new QGraphicsScene() ),
mpSceneView( new QGraphicsView( mpForm ) ),
mpLabel( new QGraphicsTextItem() ),
mpTarget( new QGraphicsRectItem() ),
mpCursor( new QGraphicsEllipseItem() )
{
BEGIN_PARAMETER_DEFINITIONS
"Application:BalloonTask float NumberOfDanger= 50.0 50.0 0.0 100.0 // The percentage of trials which have a dangerous balloon",
"Application:BalloonTask float ChanceForNormal= 75.0 75.0 0.0 100.0 // The percent chance a normal balloon will give money",
"Application:BalloonTask float ChanceForDanger= 20.0 20.0 0.0 100.0 // The percent chance a danger balloon will give money",
"Application:BalloonTask int MaxConsecRuns= 3 3 1 % // The maximum number of consecutive identical trials",
END_PARAMETER_DEFINITIONS
BEGIN_STATE_DEFINITIONS
"BalloonCode 16 0 0 0",
"TrialType 1 0 0 0", // 0: No danger balloon 1: Danger balloon present
END_STATE_DEFINITIONS
mpForm->setWindowFlags( Qt::FramelessWindowHint );
mpScene->setBackgroundBrush( QBrush( Qt::black ) );
mpSceneView->setScene( mpScene );
mpSceneView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
mpSceneView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
mpSceneView->show();
mpScene->addItem( mpLabel );
mpLabel->show();
mpScene->addItem( mpTarget );
mpTarget->setPen( Qt::NoPen );
mpTarget->hide();
mpScene->addItem( mpCursor );
mpCursor->setPen( Qt::NoPen );
mpCursor->hide();
mpForm->hide();
}
And the preflight and initialize:
Code: Select all
void
BalloonTask::OnPreflight( const SignalProperties& Input) const
{
Parameter( "WindowHeight" );
Parameter( "WindowWidth" );
Parameter( "WindowLeft" );
Parameter( "WindowTop" );
if( Parameter( "FeedbackDuration" ).InSampleBlocks() <= 0 )
bcierr << "FeedbackDuration must be greater 0" << endl;
Parameter( "NumberOfTrials");
if( Parameter( "NumberOfTrials" )<Parameter( "MaxConsecRuns" ) )
bcierr << "Must have more total trials than maximum identical trials" << endl;
if( Parameter("LogKeyboard") == 0)
bcierr << "Turn on keyboard logging to continue. Please restart with command line argument --LogKeyboard=1" << endl;
}
void
BalloonTask::OnInitialize( const SignalProperties& /*Input*/ )
{
bcidbg << "Started OnInitialize succesfully" << endl;
mpForm->move( Parameter( "WindowLeft" ), Parameter( "WindowTop" ) );
bcidbg << "Can move mpForm" << endl;
mpForm->resize( Parameter( "WindowWidth" ), Parameter( "WindowHeight" ) );
bcidbg << "Got past mpForm" << endl;
mpSceneView->resize( Parameter( "WindowWidth" ), Parameter( "WindowHeight" ) );
mpSceneView->setSceneRect( 0, 0, Parameter( "WindowWidth"), Parameter( "WindowHeight" ) );
mpSceneView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
mpSceneView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
mpSceneView->show();
bcidbg << "Got past mpSceneView" << endl;
RGBColor textColor( RGBColor::Green );
SetLabel(LocalizableString( "Timeout" ), textColor);
bcidbg << "Got past SetLabel" << endl;
mpForm->show();
int numDanger = Parameter("NumberOfTrials")*Parameter("NumberOfDanger")/100;
for(int i=0;i<numDanger;i++){
trialList[i]=1;
}
for(int i=numDanger+1;i<Parameter("NumberOfTrials");i++){
trialList[i]=0;
}
}
The code crashes as soon as it gets to OnInitialize. I was able to find this out via printing to the operator log, more specifically, I never see the "Can move mpForm" statement show up.
I am going to go copy over the FeedbackDemo code cleanly in case I missed something vital.