rhi: Fix intro doc snippet with Vulkan

The QVulkanInstance must outlive the QRhi (if Vulkan is used).
Otherwise subtle problems may pop up upon application exit.

Pick-to: 6.6
Change-Id: Ia7074c7f53633d51cf3bbdcc84e7f578214d9648
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
bb10
Laszlo Agocs 2023-10-04 21:45:32 +02:00
parent 480b39288f
commit 1d019de6b7
1 changed files with 3 additions and 1 deletions

View File

@ -11,6 +11,9 @@ int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
#if QT_CONFIG(vulkan)
QVulkanInstance inst;
#endif
std::unique_ptr<QRhi> rhi;
#if defined(Q_OS_WIN)
QRhiD3D12InitParams params;
@ -19,7 +22,6 @@ int main(int argc, char **argv)
QRhiMetalInitParams params;
rhi.reset(QRhi::create(QRhi::Metal, &params));
#elif QT_CONFIG(vulkan)
QVulkanInstance inst;
inst.setExtensions(QRhiVulkanInitParams::preferredInstanceExtensions());
if (inst.create()) {
QRhiVulkanInitParams params;