Open probonopd opened 3 years ago
Working around filer-qt --desktop
specifically now by not loading the qss for it...
Working around filer-qt --desktop specifically now by not loading the qss for it...
https://github.com/helloSystem/QtPlugin/commit/3bd2f1b6d6e6fb3a6fcdf972871165e46de2011f
As a result, Filer and the Desktop Preferences are not styled using the stylesheet.
So the question is, why does filer-qt --desktop
crash when the workaround is not there.
When it is crashing (this currently can be forced by running Filer without --desktop
(then our crude workaround is not used and it is loading stylestheet.css
) and then running Filer with --desktop
while the other one is still running:
recvmsg(4,{NULL,0,[{"\M-! \M-Q\^B\M-9\^N\M^@\^AT\^A\0"...,4096}],1,{},0,0},0) = 32 (0x20)
write(9,"\^A",1) = 1 (0x1)
poll({ 8/POLLIN 21/POLLIN 30/POLLIN },3,49) = 1 (0x1)
read(8,"\^A",16) = 1 (0x1)
poll({ 4/POLLIN },1,-1) = 1 (0x1)
recvmsg(4,{NULL,0,[{"\M-! \M-Q\^B\M-9\^N\M^@\^AT\^A\0"...,4096}],1,{},0,0},0) = 32 (0x20)
write(9,"\^A",1) = 1 (0x1)
poll({ 8/POLLIN 21/POLLIN 30/POLLIN },3,35) = 1 (0x1)
read(8,"\^A",16) = 1 (0x1)
poll({ 8/POLLIN 21/POLLIN 30/POLLIN },3,35) = 0 (0x0)
getfsstat(0x0,0,MNT_NOWAIT) = 16 (0x10)
getfsstat(0x809716300,37504,MNT_NOWAIT) = 16 (0x10)
poll({ 17/POLLIN 19/POLLIN },2,-1) = 1 (0x1)
recvmsg(19,{NULL,0,[{"l\^A\0\^A\0\0\0\0\^C\0\0\0\M^F\0"...,2048}],1,{},0,0x40000},0x40000) = 152 (0x98)
recvmsg(19,0x7fffdf7f9780,0x40000) ERR#35 'Resource temporarily unavailable'
write(18,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
poll({ 8/POLLIN 21/POLLIN 30/POLLIN },3,2996) = 1 (0x1)
read(8,"\^A",16) = 1 (0x1)
poll({ 17/POLLIN 19/POLLIN },2,0) = 1 (0x1)
read(17,"\^A",16) = 1 (0x1)
sendmsg(19,{NULL,0,[{"l\^B\^A\^A.\t\0\0\M-\\0\0\0\^_\0"...,48},{")\t\0\0<!DOCTYPE node PUBLIC "-/"...,2350}],2,{},0,0},MSG_NOSIGNAL) = 2398 (0x95e)
poll({ 17/POLLIN 19/POLLIN },2,-1) = 1 (0x1)
read(17,"\^A",16) = 1 (0x1)
write(18,"\^A",1) = 1 (0x1)
poll({ 17/POLLIN 19/POLLIN },2,-1) = 1 (0x1)
recvmsg(19,{NULL,0,[{"l\^A\0\^A\^D\0\0\0\^F\0\0\0~\0\0"...,2048}],1,{},0,0x40000},0x40000) = 148 (0x94)
recvmsg(19,0x7fffdf7f9780,0x40000) ERR#35 'Resource temporarily unavailable'
write(18,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
poll({ 17/POLLIN 19/POLLIN },2,0) = 1 (0x1)
read(17,"\^A",16) = 1 (0x1)
poll({ 8/POLLIN 21/POLLIN 30/POLLIN },3,1973) = 1 (0x1)
read(8,"\^A",16) = 1 (0x1)
desktopManager: 1
write(2,"desktopManager: 1\n",18) = 18 (0x12)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
probono: FolderItemDelegate::FolderItemDelegate created
write(2,"probono: FolderItemDelegate::Fol"...,56) = 56 (0x38)
probono: FileLauncher created
write(2,"probono: FileLauncher created\n",30) = 30 (0x1e)
SIGNAL 11 (SIGSEGV) code=SEGV_MAPERR trapno=12 addr=0x8
poll({ 4/POLLIN },1,-1) ERR#4 'Interrupted system call'
<thread 100638 exited>
<thread 100640 exited>
<thread 100650 exited>
<thread 100642 exited>
<thread 100643 exited>
process killed, signal = 11
When it is not loading the stylesheet because it was directly invoked with with --desktop
, then it looks like this:
desktopManager: 1
write(2,"desktopManager: 1\n",18) = 18 (0x12)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
write(9,"\^A",1) = 1 (0x1)
probono: FolderItemDelegate::FolderItemDelegate created
write(2,"probono: FolderItemDelegate::Fol"...,56) = 56 (0x38)
access("/usr/local/etc/fonts/fonts.conf",R_OK) = 0 (0x0)
access("/usr/local/etc/fonts/fonts.conf",R_OK) = 0 (0x0)
readlink("/usr/local/etc/fonts/fonts.conf",0x7fffffffc180,1023) ERR#22 'Invalid argument'
fstatat(AT_FDCWD,"/usr/local/etc/fonts/fonts.conf",{ mode=-rw-r--r-- ,inode=132655,size=2852,blksize=4096 },0x0) = 0 (0x0)
openat(AT_FDCWD,"/usr/local/etc/fonts/fonts.conf",O_RDONLY|O_CLOEXEC,00) = 22 (0x16)
read(22,"<?xml version="1.0"?>\n<!DOCTYPE"...,1024) = 1024 (0x400)
read(22,"s.\n\n\tKeith Packard\n-->\n\n<!"...,1024) = 1024 (0x400)
read(22,"string>sans-serif</string>\n\t\t"...,1024) = 804 (0x324)
read(22,0x7fffffffca90,1024) = 0 (0x0)
close(22) = 0 (0x0)
getrandom("&\M-4h\240\M-A 8\M^O\M-v\M-_F"...,40,0) = 40 (0x28)
mmap(0x0,1104,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34461900800 (0x80616e000)
minherit(0x80616e000,1104,INHERIT_ZERO) = 0 (0x0)
access("/usr/local/etc/fonts/conf.d",R_OK) = 0 (0x0)
access("/usr/local/etc/fonts/conf.d",R_OK) = 0 (0x0)
So when it does not crash, it does some font loading related work. Is this the part that is crashing when there is a stylesheet.qss
file?
Looking at the code, there is an invocation of QStyledItemDelegate
near probono: FolderItemDelegate::FolderItemDelegate created
- coincidence?
We have some calls to the obsolete QStyleOptionViewItemV4
which probably should be ported to QStyleOptionViewItem
.
However, we have those in both folderitemdelegate.cpp
and in desktopitemdelegate.cpp
. The crash only happens when the desktop is being shown. So most likely what is causing it must be in the latter but not the former...
We have a QStyleOptionViewItemV4
there.
Replacing the V4
s does not prevent the crash. They are probably just aliases anyway https://doc.qt.io/archives/qt-5.11/qstyleoptionviewitem-obsolete.html.
This can be reproduced with a way simpler style plugin, based on the Qt example "SimpleStyle" that comes with Qt Creator, with only one method in simplestyle.cpp
:
void SimpleStyle::polish(QApplication* app)
{
qDebug() << "probono: SimpleStyle::polish(QApplication* app)";
QCommonStyle::polish(app);
app->setPalette(standardPalette());
// probono: Use ~/.config/stylesheet.qss or /etc/xdg/tylesheet.qss if exists
QString qsspath;
qsspath = QStandardPaths::locate(QStandardPaths::ConfigLocation, QStringLiteral("stylesheet.qss"), QStandardPaths::LocateFile);
if(qsspath.isEmpty() == false) {
QMessageBox *msgBox = new QMessageBox(QMessageBox::NoIcon, "Title", qsspath);
msgBox->exec();
QFile File(qsspath);
File.open(QFile::ReadOnly);
QString StyleSheet = QLatin1String(File.readAll());
app->setStyleSheet(StyleSheet);
}
}
If we build this, then
sudo cp ~/build-styleplugin-Desktop-Debug/styles/libsimplestyleplugin.so /usr/local/lib/qt5/plugins/styles/
and then run QT_QPA_PLATFORMTHEME="" QT_STYLE_OVERRIDE=simplestyle /System/Filer.AppDir/AppRun
followed by QT_QPA_PLATFORMTHEME="" QT_STYLE_OVERRIDE=simplestyle /System/Filer.AppDir/AppRun --desktop
, then we also get the crash.
If I comment out the app->setStyleSheet(StyleSheet);
above then it does not crash.
If I replace the line with app->setStyleSheet("");
then it does not crash.
If I replace the line with app->setStyleSheet("QObject { font-size: 14pt; }");
or with app->setStyleSheet("QObject { }");
then it also crashes.
Interesting: When setStyleSheet to anything but ""
then SimpleStyle::polish(QApplication* app)
seems to get called twice. Maybe polish
is not the correct place to hook this in?
If we apply the same stylesheet not through this plugin but in Filer filer.cpp
as shown below, then it does not crash and the qss does get applied (but as soon as there is anything in the qss file, even a comment, then the desktop background is always white, the font-related settings of Filer are ignored and the stylesheet always "wins").
This shows that one can set a stylesheet without Filer crashing when the desktop is rendered, but with weird side effects and not in the way we are trying to do it in this plugin... so it may well be that we need to turn out attention the Filer's desktop drawing code (as well)...
#include <libfm/fm.h>
#include "application.h"
#include "libfmqt.h"
#include <QStandardPaths>
#include <QMessageBox>
int main(int argc, char** argv) {
// ensure that glib integration of Qt is not turned off
// This fixes #168: https://github.com/lxde/filer-qt/issues/168
qunsetenv("QT_NO_GLIB");
Filer::Application app(argc, argv);
app.init();
// ----------------------------------------------------------------------------------------
// probono: Use ~/.config/stylesheet.qss or /etc/xdg/stylesheet.qss if exists
// FIXME: This is a workaround for the workaround in
// https://github.com/helloSystem/QtPlugin/commit/3bd2f1b6d6e6fb3a6fcdf972871165e46de2011f
// to temporarily fix https://github.com/helloSystem/Utilities/issues/48 until
// https://github.com/helloSystem/QtPlugin/issues/2
// is properly resolved.
QString qsspath;
qsspath = QStandardPaths::locate(QStandardPaths::ConfigLocation, QStringLiteral("stylesheet.qss"), QStandardPaths::LocateFile);
if(qsspath.isEmpty() == false) {
QFile File(qsspath);
File.open(QFile::ReadOnly);
QString StyleSheet = QLatin1String(File.readAll());
app.setStyleSheet(StyleSheet);
}
// ----------------------------------------------------------------------------------------
return app.exec();
}
Another application where this can be reproduced with:
https://github.com/mildred/qfm
When using QT_QPA_PLATFORMTHEME=panda
(as is the default on helloSystem), then
/usr/local/etc/xdg/stylesheet.qss
existsSo it's definitely not a Filer bug.
Closed then?
Hesitant to close this as long the bug can be reproduced with https://github.com/mildred/qfm. While it is possible that it is not a QtPlugin bug it seems like it gets triggered when QtPlugin and a non-empty qss file are used.
Why?
Is it a fault of https://github.com/helloSystem/Filer or a fault of QtPlugin?