0

我将在我的 Qt 应用程序中使用dxflib 。构建过程没问题,但是当我要运行它时,应用程序从一开始就停止工作,并出现以下错误:

Unhandled exception at 0x776415de in DXFOpen.exe: 0xC00000FD: Stack overflow.

这是我的简单应用程序:

class CreatorAdaptor : public DL_CreationAdapter
{
    QGraphicsScene *_scene;
public:
    explicit CreatorAdaptor(QGraphicsScene *scene);
    virtual void addLine(const DL_LineData &d);
    virtual void addLayer(const DL_LayerData& data);
    virtual void addPoint(const DL_PointData& data);
    virtual void addArc(const DL_ArcData& data);
    virtual void addCircle(const DL_CircleData& data);
    virtual void addPolyline(const DL_PolylineData& data);
    virtual void addVertex(const DL_VertexData& data);
    virtual void add3dFace(const DL_3dFaceData& data);


};

以及类的定义:

CreatorAdaptor::CreatorAdaptor(QGraphicsScene *scene) :_scene(scene)
{
}

void CreatorAdaptor::addLine(const DL_LineData &d)
{
    qDebug()<<"add line";
    _scene->addLine(d.x1, d.y1, d.x2, d.y2);
}
...

这是我的主要内容:

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QGraphicsView  *view = new QGraphicsView;
    QGraphicsScene  * scene = new QGraphicsScene;
    view->setScene(scene);
    CreatorAdaptor *dxfscene = new CreatorAdaptor(scene);
    DL_Dxf dxf;
     if(dxf.in("demo.dxf", dxfscene))
         QMessageBox::warning(0,"error", "error");
    view->show();
    return a.exec();
}

调用堆栈:

    ntdll.dll!77af15de()    
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] 
    ntdll.dll!77af15de()    
    ntdll.dll!77ae014e()    
    kernel32.dll!755e14dd()     
>   msvcr100d.dll!_free_base(void * pBlock)  Line 50 + 0x13 bytes   C
    0041f648()  
    QtCored4.dll!qFree(void * ptr)  Line 60 + 0xa bytes C++
    QtCored4.dll!QVectorData::free(QVectorData * x, int alignment)  Line 82 + 0x9 bytes C++
    QtCored4.dll!QVectorTypedData<char *>::free(QVectorTypedData<char *> * x, int alignment)  Line 99 + 0x10 bytes  C++
    QtCored4.dll!QVector<char *>::free(QVectorTypedData<char *> * x)  Line 468 + 0x12 bytes C++
    QtCored4.dll!QVector<char *>::~QVector<char *>()  Line 124 + 0x30 bytes C++
    QtCored4.dll!qWinMain(HINSTANCE__ * instance, HINSTANCE__ * prevInstance, char * cmdParam, int cmdShow, int & argc, QVector<char *> & argv)  Line 193   C++
    0041f7e0()  
    DXFOpen.exe!__security_init_cookie()  Line 143  C
    DXFOpen.exe!WinMainCRTStartup()  Line 371   C
    kernel32.dll!755e339a()     
    ntdll.dll!77b09ef2()    
    ntdll.dll!77b09ec5()    
4

1 回答 1

2

我认为你必须像下面那样编写所有的虚函数:

void CreatorAdaptor::addLine(const DL_LineData &d){
     // something something
}

您可以将它们留空,但您必须定义它们,因为它们在 dxf 库中被定义为虚函数。当然,另一种选择是删除 CreatorAdaptor 类中的所有虚函数定义。

于 2017-03-31T13:40:45.330 回答