eglfs: find correct framebuffer index even if device node is symlink

Using the Vivante driver on a board with different device trees I found the need
to let udev point me to the framebuffer actually connected to HDMI by adding a
symlink. Since the extraction of the framebuffer index failed and always
returned 0 the GUI still always showed up on the first framebuffer.

Change-Id: Ib4aa0fdd6e85d296c17fd977921cbc78e52dcdcf
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit dd23313d66846022894b56ad25b6c2c0fdb54762)
This commit is contained in:
Rolf Eike Beer 2020-01-17 16:02:31 +01:00
parent 5e32c51b7a
commit 303e9168eb

View File

@ -52,6 +52,7 @@
#include <QScreen> #include <QScreen>
#include <QDir> #include <QDir>
#if QT_CONFIG(regularexpression) #if QT_CONFIG(regularexpression)
# include <QFileInfo>
# include <QRegularExpression> # include <QRegularExpression>
#endif #endif
#include <QLoggingCategory> #include <QLoggingCategory>
@ -144,7 +145,12 @@ int QEglFSDeviceIntegration::framebufferIndex() const
int fbIndex = 0; int fbIndex = 0;
#if QT_CONFIG(regularexpression) #if QT_CONFIG(regularexpression)
QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)")); QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)"));
QRegularExpressionMatch match = fbIndexRx.match(QString::fromLocal8Bit(fbDeviceName())); QFileInfo fbinfo(QString::fromLocal8Bit(fbDeviceName()));
QRegularExpressionMatch match;
if (fbinfo.isSymLink())
match = fbIndexRx.match(fbinfo.symLinkTarget());
else
match = fbIndexRx.match(fbinfo.fileName());
if (match.hasMatch()) if (match.hasMatch())
fbIndex = match.captured(1).toInt(); fbIndex = match.captured(1).toInt();
#endif #endif