mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-12-23 19:25:37 -05:00
Update qcustomplot component for Qt v5.14 compatibility
This commit is contained in:
parent
399b0caafe
commit
eb7681c7c5
@ -1104,8 +1104,8 @@ void QCPLayer::setMode(QCPLayer::LayerMode mode)
|
||||
if (mMode != mode)
|
||||
{
|
||||
mMode = mode;
|
||||
if (!mPaintBuffer.isNull())
|
||||
mPaintBuffer.data()->setInvalidated();
|
||||
if (auto paint_buffer = mPaintBuffer.toStrongRef())
|
||||
paint_buffer->setInvalidated();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1140,16 +1140,15 @@ void QCPLayer::draw(QCPPainter *painter)
|
||||
*/
|
||||
void QCPLayer::drawToPaintBuffer()
|
||||
{
|
||||
if (!mPaintBuffer.isNull())
|
||||
{
|
||||
if (QCPPainter *painter = mPaintBuffer.data()->startPainting())
|
||||
if (auto paint_buffer = mPaintBuffer.toStrongRef()) {
|
||||
if (auto painter = paint_buffer->startPainting())
|
||||
{
|
||||
if (painter->isActive())
|
||||
draw(painter);
|
||||
else
|
||||
qDebug() << Q_FUNC_INFO << "paint buffer returned inactive painter";
|
||||
delete painter;
|
||||
mPaintBuffer.data()->donePainting();
|
||||
paint_buffer->donePainting();
|
||||
} else
|
||||
qDebug() << Q_FUNC_INFO << "paint buffer returned zero painter";
|
||||
} else
|
||||
@ -1173,11 +1172,11 @@ void QCPLayer::replot()
|
||||
{
|
||||
if (mMode == lmBuffered && !mParentPlot->hasInvalidatedPaintBuffers())
|
||||
{
|
||||
if (!mPaintBuffer.isNull())
|
||||
if (auto paint_buffer = mPaintBuffer.toStrongRef())
|
||||
{
|
||||
mPaintBuffer.data()->clear(Qt::transparent);
|
||||
paint_buffer->clear(Qt::transparent);
|
||||
drawToPaintBuffer();
|
||||
mPaintBuffer.data()->setInvalidated(false);
|
||||
paint_buffer->setInvalidated(false);
|
||||
mParentPlot->update();
|
||||
} else
|
||||
qDebug() << Q_FUNC_INFO << "no valid paint buffer associated with this layer";
|
||||
@ -1203,8 +1202,8 @@ void QCPLayer::addChild(QCPLayerable *layerable, bool prepend)
|
||||
mChildren.prepend(layerable);
|
||||
else
|
||||
mChildren.append(layerable);
|
||||
if (!mPaintBuffer.isNull())
|
||||
mPaintBuffer.data()->setInvalidated();
|
||||
if (auto paint_buffer = mPaintBuffer.toStrongRef())
|
||||
paint_buffer->setInvalidated();
|
||||
} else
|
||||
qDebug() << Q_FUNC_INFO << "layerable is already child of this layer" << reinterpret_cast<quintptr>(layerable);
|
||||
}
|
||||
@ -1222,8 +1221,8 @@ void QCPLayer::removeChild(QCPLayerable *layerable)
|
||||
{
|
||||
if (mChildren.removeOne(layerable))
|
||||
{
|
||||
if (!mPaintBuffer.isNull())
|
||||
mPaintBuffer.data()->setInvalidated();
|
||||
if (auto paint_buffer = mPaintBuffer.toStrongRef())
|
||||
paint_buffer->setInvalidated();
|
||||
} else
|
||||
qDebug() << Q_FUNC_INFO << "layerable is not child of this layer" << reinterpret_cast<quintptr>(layerable);
|
||||
}
|
||||
@ -11067,12 +11066,12 @@ QCPItemAnchor::QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentIte
|
||||
QCPItemAnchor::~QCPItemAnchor()
|
||||
{
|
||||
// unregister as parent at children:
|
||||
foreach (QCPItemPosition *child, mChildrenX.toList())
|
||||
foreach (QCPItemPosition *child, mChildrenX.values())
|
||||
{
|
||||
if (child->parentAnchorX() == this)
|
||||
child->setParentAnchorX(0); // this acts back on this anchor and child removes itself from mChildrenX
|
||||
}
|
||||
foreach (QCPItemPosition *child, mChildrenY.toList())
|
||||
foreach (QCPItemPosition *child, mChildrenY.values())
|
||||
{
|
||||
if (child->parentAnchorY() == this)
|
||||
child->setParentAnchorY(0); // this acts back on this anchor and child removes itself from mChildrenY
|
||||
@ -11245,12 +11244,12 @@ QCPItemPosition::~QCPItemPosition()
|
||||
// unregister as parent at children:
|
||||
// Note: this is done in ~QCPItemAnchor again, but it's important QCPItemPosition does it itself, because only then
|
||||
// the setParentAnchor(0) call the correct QCPItemPosition::pixelPosition function instead of QCPItemAnchor::pixelPosition
|
||||
foreach (QCPItemPosition *child, mChildrenX.toList())
|
||||
foreach (QCPItemPosition *child, mChildrenX.values())
|
||||
{
|
||||
if (child->parentAnchorX() == this)
|
||||
child->setParentAnchorX(0); // this acts back on this anchor and child removes itself from mChildrenX
|
||||
}
|
||||
foreach (QCPItemPosition *child, mChildrenY.toList())
|
||||
foreach (QCPItemPosition *child, mChildrenY.values())
|
||||
{
|
||||
if (child->parentAnchorY() == this)
|
||||
child->setParentAnchorY(0); // this acts back on this anchor and child removes itself from mChildrenY
|
||||
@ -13857,8 +13856,8 @@ bool QCustomPlot::removeLayer(QCPLayer *layer)
|
||||
if (layer == mCurrentLayer)
|
||||
setCurrentLayer(targetLayer);
|
||||
// invalidate the paint buffer that was responsible for this layer:
|
||||
if (!layer->mPaintBuffer.isNull())
|
||||
layer->mPaintBuffer.data()->setInvalidated();
|
||||
if (auto paint_buffer = layer->mPaintBuffer.toStrongRef())
|
||||
paint_buffer->setInvalidated();
|
||||
// remove layer:
|
||||
delete layer;
|
||||
mLayers.removeOne(layer);
|
||||
@ -13894,10 +13893,10 @@ bool QCustomPlot::moveLayer(QCPLayer *layer, QCPLayer *otherLayer, QCustomPlot::
|
||||
mLayers.move(layer->index(), otherLayer->index() + (insertMode==limAbove ? 0:-1));
|
||||
|
||||
// invalidate the paint buffers that are responsible for the layers:
|
||||
if (!layer->mPaintBuffer.isNull())
|
||||
layer->mPaintBuffer.data()->setInvalidated();
|
||||
if (!otherLayer->mPaintBuffer.isNull())
|
||||
otherLayer->mPaintBuffer.data()->setInvalidated();
|
||||
if (auto paint_buffer = layer->mPaintBuffer.toStrongRef())
|
||||
paint_buffer->setInvalidated();
|
||||
if (auto paint_buffer = otherLayer->mPaintBuffer.toStrongRef())
|
||||
paint_buffer->setInvalidated();
|
||||
|
||||
updateLayerIndices();
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user