我在我的插件中使用 qwt5 和 qgis 2.8.1((32 位版本),它使用 qwt6)。当我运行我的 C++ 程序时,它崩溃并出现此错误:
问题出现在这个函数中(在debug中运行):
//delete all the items attached to QwtPlot
const QwtPlotItemList &list = m_pPlot->itemList ();
qDeleteAll(list.begin(), list.end());
我将此函数替换为:
QwtPlotItemIterator it = list.begin();
while ( it != list.end() )
{
QwtPlotItem *item = *it;
++it; // increment before removing item from the list
item->attach(NULL);
delete item;
}
但在这条指令中再次发生同样的崩溃:
delete item;
请问,您对这个问题有什么想法吗?
最佳答案
A QwtPlotItemList of all attached plot items.
Use caution when iterating these lists, as removing/detaching an item will invalidate the iterator. Instead you can place pointers to objects to be removed in a removal list, and traverse that list later.
强调我的。
关于c++ - 崩溃 : this may be due to a corruption of the heap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29491024/