Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/fbdev/fb_backend.cpp
Show All 18 Lines | |||||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "fb_backend.h" | 20 | #include "fb_backend.h" | ||
21 | #include "composite.h" | 21 | #include "composite.h" | ||
22 | #include "logging.h" | 22 | #include "logging.h" | ||
23 | #include "logind.h" | 23 | #include "logind.h" | ||
24 | #include "scene_qpainter_fb_backend.h" | 24 | #include "scene_qpainter_fb_backend.h" | ||
25 | #include "screens.h" | 25 | #include "screens.h" | ||
26 | #include "virtual_terminal.h" | 26 | #include "virtual_terminal.h" | ||
27 | #include "udev.h" | ||||
27 | // system | 28 | // system | ||
28 | #include <fcntl.h> | 29 | #include <fcntl.h> | ||
29 | #include <unistd.h> | 30 | #include <unistd.h> | ||
30 | #include <sys/ioctl.h> | 31 | #include <sys/ioctl.h> | ||
31 | #include <sys/mman.h> | 32 | #include <sys/mman.h> | ||
32 | // Linux | 33 | // Linux | ||
33 | #include <linux/fb.h> | 34 | #include <linux/fb.h> | ||
34 | 35 | | |||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 76 | } else { | |||
76 | connect(logind, &LogindIntegration::connectedChanged, this, takeControl); | 77 | connect(logind, &LogindIntegration::connectedChanged, this, takeControl); | ||
77 | } | 78 | } | ||
78 | VirtualTerminal::create(this); | 79 | VirtualTerminal::create(this); | ||
79 | } | 80 | } | ||
80 | 81 | | |||
81 | void FramebufferBackend::openFrameBuffer() | 82 | void FramebufferBackend::openFrameBuffer() | ||
82 | { | 83 | { | ||
83 | VirtualTerminal::self()->init(); | 84 | VirtualTerminal::self()->init(); | ||
84 | int fd = LogindIntegration::self()->takeDevice(deviceIdentifier().constData()); | 85 | QString framebufferDevice = deviceIdentifier().constData(); | ||
86 | if (framebufferDevice.isEmpty()) { | ||||
87 | framebufferDevice = QString(Udev().primaryFramebuffer()->devNode()); | ||||
88 | } | ||||
89 | int fd = LogindIntegration::self()->takeDevice(framebufferDevice.toUtf8().constData()); | ||||
anthonyfieroni: strdup allocates memory and you should call free to prevent memory leaks. To use QString is… | |||||
You use udev only here, so you can write it like that framebufferDevice = Udev().primaryFramebuffer()->devNode() i.e. make Udev local to this scope. I see potentially primaryFramebuffer can return nullptr which will cause a crash without exclusive check. anthonyfieroni: You use udev only here, so you can write it like that
```
framebufferDevice = Udev(). | |||||
90 | qCDebug(KWIN_FB) << "Using frame buffer device:" << framebufferDevice; | ||||
85 | if (fd < 0) { | 91 | if (fd < 0) { | ||
86 | qCWarning(KWIN_FB) << "Failed to open frame buffer device through logind, trying without"; | 92 | qCWarning(KWIN_FB) << "Failed to open frame buffer device:" << framebufferDevice << "through logind, trying without"; | ||
graesslin: Coding style nitpick: please use {} | |||||
87 | } | 93 | } | ||
88 | fd = open(deviceIdentifier().constData(), O_RDWR | O_CLOEXEC); | 94 | fd = open(framebufferDevice.toUtf8().constData(), O_RDWR | O_CLOEXEC); | ||
89 | if (fd < 0) { | 95 | if (fd < 0) { | ||
90 | qCWarning(KWIN_FB) << "failed to open frame buffer device"; | 96 | qCWarning(KWIN_FB) << "failed to open frame buffer device:" << framebufferDevice; | ||
91 | emit initFailed(); | 97 | emit initFailed(); | ||
92 | return; | 98 | return; | ||
93 | } | 99 | } | ||
94 | m_fd = fd; | 100 | m_fd = fd; | ||
95 | if (!queryScreenInfo()) { | 101 | if (!queryScreenInfo()) { | ||
96 | qCWarning(KWIN_FB) << "failed to query framebuffer information"; | 102 | qCWarning(KWIN_FB) << "failed to query framebuffer information"; | ||
97 | emit initFailed(); | 103 | emit initFailed(); | ||
98 | return; | 104 | return; | ||
▲ Show 20 Lines • Show All 134 Lines • Show Last 20 Lines |
strdup allocates memory and you should call free to prevent memory leaks. To use QString is easier.