1. axis.cpp 1650
QList<QCPAbstractItem*> QCPAxis::items() const
For example we have func:
void MainWindow::addLineOnAxisDoubleClick(QCPAxis *axis)
{
QCPItemStraightLine * line = new QCPItemStraightLine(ui->customPlot);
ui->customPlot->addItem(line);
QList<QCPAbstractItem*> lst = axis->items();
}
...
for (int posId=0; posId<positions.size(); ++itemId)
{
if (positions.at(posId)->keyAxis() == this || positions.at(posId)->valueAxis() == this)
{
result.append(mParentPlot->mItems.at(itemId));
break;
}
}
...
If axis is
QCPAxis::atLeft
or
QCPAxis::atBottom
everything will be ok, and if
QCPAxis::atRight
or
QCPAxis::atTop
will be infity loop in
axis->items()
.
if (positions.at(posId)->keyAxis() == this || positions.at(posId)->valueAxis() == this)
never will be fulfilled and for next iteration posId
will remain same. Infity loop.
With my previous proposal axis->items()
will return empty list if QCPAxis::atRight
or QCPAxis::atTop
.
Therefore I propose:
...
for (int posId=0; posId<positions.size(); ++posId)
{
QCPAxisRect * axisRect = positions.at(posId)->axisRect();
if (positions.at(posId)->keyAxis() == this ||
positions.at(posId)->valueAxis() == this) ||
axisRect->axis(QCPAxis::atRight) == this ||
axisRect->axis(QCPAxis::atTop) == this
{
result.append(mParentPlot->mItems.at(itemId));
break;
}
}
...
2. For second issue I not yet invented test case.