【发布时间】:2015-12-10 16:20:34
【问题描述】:
任何人都可以帮助我解决这个问题。我正在尝试使用 cmakefiles 运行应用程序。在我的程序的主文件中,当程序到达执行 QAppication 的代码行时出现分段错误。下面是片段代码:
int main(int argc, char** argv)
{
bool viewing;
parse_command_line( argc, argv );
#ifdef _GRAPHICS_
glutInit(&argc, argv);
#endif
if( viewing )
{
#ifdef _GRAPHICS_
QApplication application(argc, argv);
Viewer *viewer = new Viewer( 0, exp, argc, argv );
Interface *render = new Interface( 0, exp, viewer );
render->show();
return application.exec(); //this line causes the segmentation fault
delete viewer;
delete render;
#endif
}
}
【问题讨论】:
-
argc 或 argv 是否被 parse_command_line() 或 glutInit() 修改了?如果您尝试删除它们怎么办?
-
顺便说一句,您在 application.exec() 之后的 delete 语句永远不会被调用,因为 return 语句在那里退出了 main 函数。
-
请包含堆栈跟踪