mobileshell: Add more null checks

This commit is contained in:
Devin Lin 2025-11-25 21:08:08 -05:00
parent 0b26be6331
commit bd95aa89b4

View file

@ -95,26 +95,37 @@ void ShellUtil::launchApp(const QString &storageId)
job->start(); job->start();
} }
void ShellUtil::setInputTransparent(QQuickWindow *window, bool transparent) { void ShellUtil::setInputTransparent(QQuickWindow *window, bool transparent)
if (window) { {
Qt::WindowFlags flags = window->flags(); if (!window) {
if (transparent) { return;
flags |= Qt::WindowTransparentForInput;
} else {
flags &= ~Qt::WindowTransparentForInput;
}
window->setFlags(flags);
} }
Qt::WindowFlags flags = window->flags();
if (transparent) {
flags |= Qt::WindowTransparentForInput;
} else {
flags &= ~Qt::WindowTransparentForInput;
}
window->setFlags(flags);
} }
void ShellUtil::setWindowLayer(QQuickWindow *window, LayerShellQt::Window::Layer layer) { void ShellUtil::setWindowLayer(QQuickWindow *window, LayerShellQt::Window::Layer layer)
if (window) { {
auto layerShellWindow = LayerShellQt::Window::get(window); if (!window) {
layerShellWindow->setLayer(layer); return;
} }
auto layerShellWindow = LayerShellQt::Window::get(window);
layerShellWindow->setLayer(layer);
} }
void ShellUtil::setInputRegion(QWindow *window, const QRect &region) { void ShellUtil::setInputRegion(QWindow *window, const QRect &region)
{
if (!window) {
return;
}
auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window->handle()); auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window->handle());
if (!waylandWindow) { if (!waylandWindow) {
qWarning() << "Failed to retrieve Wayland window handle."; qWarning() << "Failed to retrieve Wayland window handle.";
@ -152,6 +163,7 @@ void ShellUtil::setInputRegion(QWindow *window, const QRect &region) {
wl_surface_commit(surface); wl_surface_commit(surface);
} }
QString ShellUtil::toPlainText(QString htmlString) { QString ShellUtil::toPlainText(QString htmlString)
{
return QTextDocumentFragment::fromHtml(htmlString).toPlainText(); return QTextDocumentFragment::fromHtml(htmlString).toPlainText();
} }