From ef88a5c3d08165c0278f07574e3dd6975d37be01 Mon Sep 17 00:00:00 2001 From: Semih Yavuz Date: Tue, 26 Sep 2023 10:59:33 +0200 Subject: [PATCH] designer: Fix livepreview crash Show Live Preview can be triggered with key sequence Alt+P even if you are not in the designer view which results in access to invalid pointers. To fix this, replace the check in action handler with safer isValid which checks the validity of view and initialize live preview for valid contexts. Fixes: QTCREATORBUG-29642 Change-Id: I9dd1741f1de2722a7ac715a2726b6effbe91529c Reviewed-by: Thomas Hartmann --- src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.cpp b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.cpp index ebd53b7f649..f44cb0ab24d 100644 --- a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.cpp +++ b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.cpp @@ -33,7 +33,7 @@ const QByteArray livePreviewId = "LivePreview"; static void handleAction(const SelectionContext &context) { - if (context.view()->isAttached()) { + if (context.isValid()) { if (context.toggled()) { bool skipDeploy = false; if (const Target *startupTarget = ProjectManager::startupTarget()) {