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 <thomas.hartmann@qt.io>
This commit is contained in:
Semih Yavuz
2023-09-26 10:59:33 +02:00
parent 75cfa8a222
commit ef88a5c3d0

View File

@@ -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()) {