简体   繁体   English

如何解决此错误? 抛出'std :: bad_alloc'what()实例之后调用终止终止:std :: bad_alloc

[英]How I can fix this error? terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc

This is the code: Function : 这是代码:Function:

QString printDir2(QString path, int level)
{
int check =1;
QDir folder(path);

QString space;
QString buffer;
qDebug() <<"nivelul 1 \n";
for(int i=0; 1<level; i++)
    space +="    ";
qDebug() <<"nivelul 2 \n";
foreach(QFileInfo temp , folder.entryInfoList())
{
    if(check > 2)
    {
        qDebug() <<"nivelul 4 \n";
        buffer += space + temp.absoluteFilePath() + "\n";
        if(temp.isDir())
            buffer += printDir2(temp.absoluteFilePath(), ++level);
    }
    check++;
    qDebug() <<"nivelul 3 \n";
}
return buffer;

} }

and here i call the function: 在这里我调用函数:

QString drum="/home/sunny/Desktop/QT/descarca";
        str=printDir2(drum,0);
        qDebug()<<str<<"acesta este drumul";

How to fix this erorr from terminal: 如何从终端修复此erorr:
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc this is the terminal when i run ths code: http://s013.radikal.ru/i325/1501/e5/aade9346f0aa.png 抛出'std :: bad_alloc'what()实例后终止调用:std :: bad_alloc这是我运行此代码时的终端: http : //s013.radikal.ru/i325/1501/e5/aade9346f0aa.png

You may have run into infinite recursion. 您可能遇到了无限递归。

Run your program in the debugger. 在调试器中运行程序。 If you use gdb, you can issue the command catch throw before run . 如果使用gdb,则可以在run之前发出命令catch throw Then the debugger will stop when the exception is thrown. 然后,在引发异常时调试器将停止。 You may have to move up a few times to see which line in your code threw the exception. 您可能需要up移动几次才能看到代码中的哪一行引发了异常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复 C++ 错误:在抛出“std::bad_alloc”实例后调用终止。 什么():std::bad_alloc - How to fix C++ error: terminate called after throwing an instance of 'std::bad_alloc'. what(): std::bad_alloc 收到错误“在抛出&#39;std::bad_alloc&#39;what() 的实例后调用终止:std::bad_alloc” - getting error "terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc" 在抛出'std :: bad_alloc'的实例后调用终止what():std :: bad_alloc中止 - terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Aborted 在抛出“ std :: bad_alloc”实例的what():std :: bad_alloc实例后终止调用 - terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc" 我得到了我无法解决的错误:抛出&#39;std :: bad_alloc&#39;what()实例之后终止调用:std :: bad_alloc中止(核心已转储) - I get the error which i cant fix : terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Aborted (core dumped) Node.js错误“在抛出&#39;std :: bad_alloc&#39;的实例后调用终止what():std :: bad_alloc” - Node.js error “terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc” C++ 错误:在抛出 'std::bad_alloc' what(): std::bad_alloc 的实例后调用终止 - C++ error: terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc 从向量中删除指针...错误:在抛出“std::bad_alloc”实例后调用终止 what(): std::bad_alloc - Deleting a pointer from a vector... Error: terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc 多个文件的 Memory 分配错误“在抛出 'std::bad_alloc' 的实例后调用终止什么 ():std::bad_alloc” [C ++] - Memory allocation error for multiple files “terminate called after throwing an instance of 'std :: bad_alloc' what (): std :: bad_alloc” [C ++] 递归函数中的运行时错误:在抛出“std::bad_alloc”what() 实例后调用终止:std::bad_alloc - Runtime Error in a recursive function : terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM