简体   繁体   中英

QT debug error r6010 abort has been called while running perfectly

I am trying to generate QWTspectrogram using a file. there are 500 binary files to show an annimation with a slider in UI. the program works fine but sometimes it gives "debug error r6010 abort has been called" error and crashes on any random occasion I have no idea why this shows up because it is random however it depends on the change in fnum as slider moves but not at any fixed value or time(it does not appear at stationary condition). below is the code for my program

setAlpha is changed with the change in slider of UI.

void Plot::setAlpha( int alpha )
{
    fnum=alpha;
    d_spectrogram->setData( new mydata(fnum,dial) );
    d_spectrogram->attach( this );
    replot();
}

class mydata: public QwtRasterData
{
    typedef signed short int sBYTE;
    char filepath[35]; 
    sBYTE *fileBuf;    
    FILE *file = NULL; 
public:

    mydata(int fnum, int dial)
    {
        setInterval( Qt::XAxis, QwtInterval( 0, (area)-1 ) );
        setInterval( Qt::YAxis, QwtInterval( 0, (area)-1 ) );
        setInterval( Qt::ZAxis, QwtInterval( -dial, dial ) );

        {
            sprintf_s(filepath, "c:/mydata/uwpi%d.bin", fnum);
            fopen_s(&file,filepath, "rb");
            long fileSize = getFileSizex(file);
            fileBuf = new sBYTE[fileSize];
            fread(fileBuf, fileSize, 1, file);
            fclose(file);
        }
    }

    virtual double value( double x, double y ) const
    {

        int x_pos = static_cast<int>(x);
        int y_pos = static_cast<int>(y);
        const double c =  (fileBuf[ ((x_pos)+((area-y_pos)*area))]);
        return c;
    }
}

solved by using QFile, QDatasteam and QVector

thanks for your response it worked now…

QFile myfile;
myfile.setFileName(“c:/file.bin”);
if(!myfile.open(QIODevice::ReadOnly)) return;
QDataStream data(&myfile);
data.setByteOrder(QDataStream::LittleEndian);
QVector<qint16> result;
while(!data.atEnd()) { qint16 x; data >> x; result.append(x);
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM