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