How to fix the code when upgrade from QT 6.7 to 6.8 - Furthur on your experience how to pass this situation
-
Hi, I am a newbie, doing an internship and work with a software built by QT (I also work with other programming before but not QT). The old version is 6.7.3, now I am working in upgrading process, from QT 6.7.3 to 6.8.3. I met a lot of isssues due to the different of versions. I was stuck with this Qhri for sometime.
()error: non-const lvalue reference to type 'QRhi' cannot bind to a value of unrelated type 'QRhi ()non-const lvalue reference to type 'QRhi' cannot bind to a value of unrelated type 'QRhi *'
m_videoFrameTextures = QVideoTextureHelper::createTextures(m_currentFrame, rhi, resourceUpdates, std::move(m_videoFrameTextures));| ^
Firstly, do anyone have ideas what issue with this one and how can I fix it.
Moreover, in my situation, what the process you guys usually do to understand the code and learn how to fix it? Any good resource that I can check? I was pretty stressful because I don't understand all the code programmed by the previous one, especially when he is an experience one, I didn't build it from scratch so some issues pop up but I don't even know where and why it likes that. Those issue usually consumed a lot of time and my internship period is passing quickly. I want to hear your suggestion and experience to improve in the future. Thank you -
QVideoTextureHelper is a private Qt class so the first question is why do you use it at all.
then you need to pass qrhi as constant reference instead a pointer.
And please post code instead screenshots. -
Here is the original code, these function is used in calibration for frame in video.
void CalibrationMaterial::updateTextures(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
{
if (!m_frameDirty and !m_calibrationDirty)
return;if (m_frameDirty) { // keep the video frames alive until we know that they are not needed anymore Q_ASSERT(NVideoFrameSlots >= rhi->resourceLimit(QRhi::FramesInFlight)); m_videoFrameSlots[rhi->currentFrameSlot()] = m_currentFrame; // update and upload texture(s) m_videoFrameTextures = QVideoTextureHelper::createTextures(m_currentFrame, rhi, resourceUpdates, std::move(m_videoFrameTextures)); if (m_videoFrameTextures) { m_frameTexture.setData(QRhiTexture::R16, m_currentFrame.size(), nullptr, 0); m_frameTexture.setRhiTexture(m_videoFrameTextures->texture(0)); m_frameDirty = false; } else { qWarning("Failed to create video texture"); } } if (m_calibrationDirty) { m_calibrationRhiTexture.reset(rhi->newTexture(QRhiTexture::RGBA32F, m_calibrationImage.size())); m_calibrationTexture.setTextureSize(m_calibrationImage.size()); if (m_calibrationRhiTexture->create()) { QRhiTextureSubresourceUploadDescription subresDesc; subresDesc.setData(QByteArray::fromRawData( reinterpret_cast<const char *>(m_calibrationImage.constBits()), m_calibrationImage.sizeInBytes())); subresDesc.setDataStride(m_calibrationImage.bytesPerLine()); QRhiTextureUploadEntry entry(0, 0, subresDesc); QRhiTextureUploadDescription desc({ entry }); resourceUpdates->uploadTexture(m_calibrationRhiTexture.get(), desc); m_calibrationTexture.setTexture(m_calibrationRhiTexture.get()); m_calibrationDirty = false; } else { qWarning("Failed to create calibration texture"); } }
}
//=======================
void updateTextures(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates);
//=======================
The previous one who built this app did that, used the private header and also changed something in it. I don't understand much about that, that why I said it hard to understand especially he is experience one.
-
If I try to change to pass qrhi as constant reference instead a pointer, it would have some issue to the other functions.
@Videas
This is what happens when people write code to call undocumented/non-public functions.
As per https://codebrowser.dev/qt6/qtmultimedia/src/multimedia/video/qvideotexturehelper.cpp.html#_ZN19QVideoTextureHelper14createTexturesERK11QVideoFrameR4QRhiR23QRhiResourceUpdateBatchSt10unique_ptrI19QVideoFrameTexturesSt14default_deleteIS8_EE, if you are trying to callQVideoFrameTexturesUPtr createTextures(const QVideoFrame &frame, QRhi &rhi, QRhiResourceUpdateBatch &rub, QVideoFrameTexturesUPtr oldTextures)
did you try passing
*rhi
in place of where you passrhi
? -
If I try to change to pass qrhi as constant reference instead a pointer, it would have some issue to the other functions.
@Videas said in How to fix the code when upgrade from QT 6.7 to 6.8 - Furthur on your experience how to pass this situation:
it would have some issue to the other functions
What issue?
-
@Videas
This is what happens when people write code to call undocumented/non-public functions.
As per https://codebrowser.dev/qt6/qtmultimedia/src/multimedia/video/qvideotexturehelper.cpp.html#_ZN19QVideoTextureHelper14createTexturesERK11QVideoFrameR4QRhiR23QRhiResourceUpdateBatchSt10unique_ptrI19QVideoFrameTexturesSt14default_deleteIS8_EE, if you are trying to callQVideoFrameTexturesUPtr createTextures(const QVideoFrame &frame, QRhi &rhi, QRhiResourceUpdateBatch &rub, QVideoFrameTexturesUPtr oldTextures)
did you try passing
*rhi
in place of where you passrhi
?@JonB Oh, right. I just did and it worked. I was tried to change CalibrationMaterial::updateTextures(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) to void CalibrationMaterial::updateTextures(QRhi &rhi, QRhiResourceUpdateBatch *resourceUpdates) so many other issues occured and I tried to fix them. But wit just *rhi, it solved.
-