Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions shell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ find_package(Dtk${DTK_VERSION_MAJOR} COMPONENTS Widget REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Widgets Gui WaylandClient)
find_package(TreelandProtocols REQUIRED)
pkg_check_modules(WaylandClient REQUIRED IMPORTED_TARGET wayland-client)
pkg_check_modules(X11 REQUIRED IMPORTED_TARGET x11)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Wayland-only builds still require X11

When BUILD_WITH_X11 is disabled and X11 development files are unavailable, the unconditional pkg_check_modules(X11 REQUIRED ...) lookup fails during CMake configuration, and the unconditional Xlib include in main.cpp also prevents a build without X11. The Wayland-only build cannot complete.

Gate the X11 pkg-config lookup and Xlib include on BUILD_WITH_X11.

Also at shell/main.cpp:19-20, shell/main.cpp:265, shell/CMakeLists.txt:52.

Prompt for AI agents
In `shell/CMakeLists.txt` at line 9:

**Wayland-only builds still require X11**

When `BUILD_WITH_X11` is disabled and X11 development files are unavailable, the unconditional `pkg_check_modules(X11 REQUIRED ...)` lookup fails during CMake configuration, and the unconditional Xlib include in `main.cpp` also prevents a build without X11. The Wayland-only build cannot complete.

Gate the X11 pkg-config lookup and Xlib include on `BUILD_WITH_X11`.

Also at `shell/main.cpp:19-20`, `shell/main.cpp:265`, `shell/CMakeLists.txt:52`.


if (NOT DEFINED SYSTEMD_USER_UNIT_DIR)
find_package(PkgConfig REQUIRED)
Expand Down Expand Up @@ -48,6 +49,7 @@ target_link_libraries(dde-shell PRIVATE
Dtk${DTK_VERSION_MAJOR}::Widget
Qt${QT_VERSION_MAJOR}::DBus
PkgConfig::WaylandClient
PkgConfig::X11
)

configure_file(${CMAKE_SOURCE_DIR}/misc/dde-shell-plugin@.service.in
Expand Down
9 changes: 9 additions & 0 deletions shell/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
#include <QQuickWindow>
#include <QWindow>

#include <csignal>

Check warning on line 17 in shell/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <csignal> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <iostream>

Check warning on line 18 in shell/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <iostream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <X11/Xlib.h>

Check warning on line 19 in shell/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <X11/Xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <unistd.h>

Check warning on line 20 in shell/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include "applet.h"

Check warning on line 22 in shell/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "applet.h" not found.
#include "containment.h"

Check warning on line 23 in shell/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "containment.h" not found.
#include "pluginloader.h"
#include "appletconfigmanager.h"
#include "appletloader.h"
Expand Down Expand Up @@ -134,6 +136,11 @@
QList<DAppletLoader *> m_loaders;
};

static int x11IOErrorHandler(Display *)
{
_exit(0);
}

int main(int argc, char *argv[])
{
setenv("DSG_APP_ID", "org.deepin.dde.shell", 0);
Expand Down Expand Up @@ -255,6 +262,8 @@
manager.exec();
}, Qt::QueuedConnection);

XSetIOErrorHandler(x11IOErrorHandler);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Startup X11 errors still trigger destructor crashes

When the X server connection fails during application or shell startup, before XSetIOErrorHandler is called, the default libX11 handler remains active while the application and applet setup run; it calls exit() on an I/O error, running destructors against the dead display and potentially crashing dde-shell.

Install the I/O error handler before any startup code can use the X11 connection.

Prompt for AI agents
In `shell/main.cpp` at line 265:

**Startup X11 errors still trigger destructor crashes**

When the X server connection fails during application or shell startup, before `XSetIOErrorHandler` is called, the default libX11 handler remains active while the application and applet setup run; it calls `exit()` on an I/O error, running destructors against the dead display and potentially crashing dde-shell.

Install the I/O error handler before any startup code can use the X11 connection.


QObject::connect(qApp, &QCoreApplication::aboutToQuit, qApp, [&manager]() {
qCInfo(dsLog) << "Exit dde-shell.";
DPluginLoader::instance()->destroy();
Expand Down
Loading