QtCurve / qtcurve

QtCurve Theme
47 stars 6 forks source link

Cannot use -style option with Qt5 #62

Closed kachelaqa closed 10 years ago

kachelaqa commented 10 years ago

I need to use the -style option or QT_STYLE_OVERRIDE variable with Qt5 applications, because I am not using a DE. However, I cannot get this to work with qtcurve-qt5 (I just get the default fusion style). The plugin does work if I fake a KDE desktop by setting the KDE_FULL_SESSION and KDE_SESSION_VERSION variables - but this has other side-effects which I'm keen to avoid. The -style option does work for me with other plugins, and also qtcurve with qt4 - it just seems to be qtcurve with qt5 that has the problem.

I took a look at the qt5 source to see how QT_STYLE_OVERRIDE is used. The critical point seems to be this line in QApplication::style (qapplication.cpp):

app_style = QStyleFactory::create(style);

I'm no C++ coder, so I tried the equivalent in PyQt5, and it crashes the python interpreter. All other plugins work fine, though, and I was also able to load the qtcurve-qt4 plugin with PyQt4. So there seems to be some specific problem with loading the qtcurve-qt5 plugin.

I'm using Arch Linux with Qt-5.2.1 and QtCurve-1.8.18. For testing, I am using SMPlayer-14.3.0 (built with Qt-5.2.1), like this:

$ smplayer -style=gtk+ # works as expected
$ smplayer -style=qtcurve # loads fusion style
yuyichao commented 10 years ago

On Tue, Apr 22, 2014 at 9:26 AM, kachelaqa notifications@github.com wrote:

I need to use the -style option or QT_STYLE_OVERRIDE variable with Qt5 applications, because I am not using a DE.

Hmmm, at some point I though qtconfig/editing config file works.

However, I cannot get this to work with qtcurve-qt5 (I just get the default fusion style). The plugin does work if I fake a KDE desktop by setting the KDE_FULL_SESSION and KDE_SESSION_VERSION variables - but this has other side-effects which I'm keen to avoid. The -style option does work for me with other plugins, and also qtcurve with qt4 - it just seems to be qtcurve with qt5 that has the problem.

I tried to unset some KDE envs and adding the commandline option / overriding with QT_STYLE_OVERRIDE and it seems to work here.

I took a look at the qt5 source to see how QT_STYLE_OVERRIDE is used. The critical point seems to be this line in QApplication::style (qapplication.cpp):

app_style = QStyleFactory::create(style);

I'm no C++ coder, so I tried the equivalent in PyQt5, and it crashes the python interpreter. All other plugins work fine, though, and I was also able to load the qtcurve-qt4 plugin with PyQt4. So there seems to be some specific problem with loading the qtcurve-qt5 plugin.

Is there any error message? I packaged the pyqt5 package on AUR and remember some weird error on exit in QtDBus when using qtcurve if I don't delete the app and have never figured out why. GDB might also help too.

I'm using Arch Linux with Qt-5.2.1 and QtCurve-1.8.18. For testing, I am using SMPlayer-14.3.0 (built with Qt-5.2.1), like this:

$ smplayer -style=gtk+ # works as expected $ smplayer -style=qtcurve # loads fusion style

Mee too and somehow it works here.

— Reply to this email directly or view it on GitHubhttps://github.com/QtCurve/qtcurve/issues/62 .

yuyichao commented 10 years ago

Hmmm, at some point I though qtconfig/editing config file works.

Oh sorry it was my misreading of ur AUR comment in qtcurve-qt5-git ......

yuyichao commented 10 years ago

And for getting error/debug messages setting QT_DEBUG_PLUGINS=1 might help.

kachelaqa commented 10 years ago

I tried QT_DEBUG_PLUGINS=1, but it was not much help. It shows the plugin is being loaded and unloaded, but it says nothing about whether the style was created successfully.

Here is my python test script:

# from PyQt4.QtGui import QApplication, QStyleFactory
from PyQt5.QtWidgets import QApplication, QStyleFactory

app = QApplication([])

for key in reversed(QStyleFactory.keys()):
    print('Creating %s style:' % key)
    print(QStyleFactory.create(key))

Output with PyQt4:

Creating Cleanlooks style:
<PyQt4.QtGui.QCommonStyle object at 0x7f0ca8000dc8>
Creating GTK+ style:
<PyQt4.QtGui.QCommonStyle object at 0x7f0ca8000dc8>
Creating Plastique style:
<PyQt4.QtGui.QCommonStyle object at 0x7f0ca8000dc8>
Creating CDE style:
<PyQt4.QtGui.QCommonStyle object at 0x7f0ca8000dc8>
Creating Motif style:
<PyQt4.QtGui.QCommonStyle object at 0x7f0ca8000dc8>
Creating Windows style:
<PyQt4.QtGui.QCommonStyle object at 0x7f0ca8000dc8>
Creating QtCurve style:
<PyQt4.QtGui.QCommonStyle object at 0x7f0ca8000dc8>
Creating Oxygen style:
<PyQt4.QtGui.QCommonStyle object at 0x7f0ca8000dc8>

Output with PyQt5:

Creating Fusion style:
<PyQt5.QtWidgets.QCommonStyle object at 0x7fcfbd420168>
Creating GTK+ style:
<PyQt5.QtWidgets.QCommonStyle object at 0x7fcfbd420168>
Creating Windows style:
<PyQt5.QtWidgets.QCommonStyle object at 0x7fcfbd420168>
Creating QtCurve style:
Segmentation fault (core dumped)

Output using gdb:

Creating Fusion style:
<PyQt5.QtWidgets.QCommonStyle object at 0x7fffed723168>
Creating GTK+ style:
<PyQt5.QtWidgets.QCommonStyle object at 0x7fffed723168>
Creating Windows style:
<PyQt5.QtWidgets.QCommonStyle object at 0x7fffed723168>
Creating QtCurve style:

Program received signal SIGSEGV, Segmentation fault.
0x00007fffe0bf6319 in ?? () from /usr/lib/qt/plugins/styles/qtcurve.so

Obviously, I don't have the debug symbols available, but it clearly shows that the problem lies with qtcurve.

yuyichao commented 10 years ago

Obviously, I don't have the debug symbols available, but it clearly shows that the problem lies with qtcurve.

I C. I believe I have debug in the options array for my qtcurve-git so it will build a separate debug package. It would be helpful if you could give it a try. (it will also automatically include the fix for the other bug u report. :P )

kachelaqa commented 10 years ago

Okay, gdb output using qtcurve-git:

Creating Fusion style:
<PyQt5.QtWidgets.QCommonStyle object at 0x7fffed723168>
Creating GTK+ style:
<PyQt5.QtWidgets.QCommonStyle object at 0x7fffed723168>
Creating Windows style:
<PyQt5.QtWidgets.QCommonStyle object at 0x7fffed723168>
Creating QtCurve style:

Program received signal SIGSEGV, Segmentation fault.
QString (other=..., this=0x7fffe0c6a920 <QtCurve::appName>) at /usr/include/qt/QtCore/qstring.h:766
766 { Q_ASSERT(&other != this); d->ref.ref(); }
(gdb) bt
#0  QString (other=..., this=0x7fffe0c6a920 <QtCurve::appName>) at /usr/include/qt/QtCore/qstring.h:766
#1  getFile (f=...) at /tmp/yaourt-tmp/aur-qtcurve-git/src/qtcurve/qt5/style/qtcurve.cpp:740
#2  __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535)
    at /tmp/yaourt-tmp/aur-qtcurve-git/src/qtcurve/qt5/style/qtcurve.cpp:148
#3  _GLOBAL__sub_I_qtcurve.cpp(void) () at /tmp/yaourt-tmp/aur-qtcurve-git/src/qtcurve/qt5/style/qtcurve.cpp:4341
#4  0x00007ffff7dea9ca in call_init.part () from /lib64/ld-linux-x86-64.so.2
#5  0x00007ffff7deaab3 in _dl_init_internal () from /lib64/ld-linux-x86-64.so.2
#6  0x00007ffff7deec08 in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
#7  0x00007ffff7dea884 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#8  0x00007ffff7dee3fb in _dl_open () from /lib64/ld-linux-x86-64.so.2
#9  0x00007ffff718a02b in ?? () from /usr/lib/libdl.so.2
#10 0x00007ffff7dea884 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#11 0x00007ffff718a5dd in ?? () from /usr/lib/libdl.so.2
#12 0x00007ffff718a0c1 in dlopen () from /usr/lib/libdl.so.2
#13 0x00007ffff506dc3a in ?? () from /usr/lib/libQt5Core.so.5
#14 0x00007ffff5068e95 in ?? () from /usr/lib/libQt5Core.so.5
#15 0x00007ffff5069c8b in ?? () from /usr/lib/libQt5Core.so.5
#16 0x00007ffff5061580 in QFactoryLoader::instance(int) const () from /usr/lib/libQt5Core.so.5
#17 0x00007ffff5c7ded9 in QStyleFactory::create(QString const&) () from /usr/lib/libQt5Widgets.so.5
#18 0x00007ffff668e296 in ?? () from /usr/lib/python3.4/site-packages/PyQt5/QtWidgets.so
#19 0x00007ffff7a67a87 in call_function (oparg=<optimized out>, pp_stack=0x7fffffffe330) at Python/ceval.c:4227
#20 PyEval_EvalFrameEx (f=f@entry=0x7ffff6bea438, throwflag=throwflag@entry=0) at Python/ceval.c:2829
#21 0x00007ffff7a68c8e in PyEval_EvalCodeEx (_co=_co@entry=0x7ffff6b56f60, globals=globals@entry=0x7ffff6be7308, locals=locals@entry=0x7ffff6be7308,
    args=args@entry=0x0, argcount=argcount@entry=0, kws=kws@entry=0x0, kwcount=kwcount@entry=0, defs=defs@entry=0x0, defcount=defcount@entry=0,
    kwdefs=kwdefs@entry=0x0, closure=closure@entry=0x0) at Python/ceval.c:3578
#22 0x00007ffff7a68d5b in PyEval_EvalCode (co=co@entry=0x7ffff6b56f60, globals=globals@entry=0x7ffff6be7308, locals=locals@entry=0x7ffff6be7308)
    at Python/ceval.c:773
#23 0x00007ffff7a84464 in run_mod (mod=mod@entry=0x68c690, filename=filename@entry=0x7ffff6ade030, globals=globals@entry=0x7ffff6be7308,
    locals=locals@entry=0x7ffff6be7308, flags=flags@entry=0x7fffffffe5f0, arena=arena@entry=0x6da610) at Python/pythonrun.c:2175
#24 0x00007ffff7a8653d in PyRun_FileExFlags (fp=fp@entry=0x68bcf0, filename_str=filename_str@entry=0x7ffff6bde320 "test2.py", start=start@entry=257,
    globals=globals@entry=0x7ffff6be7308, locals=locals@entry=0x7ffff6be7308, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffe5f0)
    at Python/pythonrun.c:2128
#25 0x00007ffff7a87421 in PyRun_SimpleFileExFlags (fp=fp@entry=0x68bcf0, filename=<optimized out>, closeit=closeit@entry=1,
    flags=flags@entry=0x7fffffffe5f0) at Python/pythonrun.c:1601
#26 0x00007ffff7a88263 in PyRun_AnyFileExFlags (fp=fp@entry=0x68bcf0, filename=<optimized out>, closeit=closeit@entry=1,
    flags=flags@entry=0x7fffffffe5f0) at Python/pythonrun.c:1288
#27 0x00007ffff7a9c97c in run_file (p_cf=0x7fffffffe5f0, filename=0x629ff0 L"test2.py", fp=0x68bcf0) at Modules/main.c:319
#28 Py_Main (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:751
#29 0x0000000000400af9 in main ()

(BTW: issue #61 is now fixed for me: thanks)

yuyichao commented 10 years ago

err. I mean ... can you paste the output of bt or bt full after the crash ..... the crash point itself just looks random.

kachelaqa commented 10 years ago

Sorry, I'm not sure what you mean: that is the output of bt after the segfault.

yuyichao commented 10 years ago

k, fine ... it wasn't like that before u edit it. I wrote my comment right after seeing ur old comment but somehow didn't send it out and sent it out just now without refreshing the page.

yuyichao commented 10 years ago

K, I know what happend. I can try to get around this problem but I don't think that is the cause of ur problem.

Can you replace app = QApplication([]) with app = QApplication(['python']) and run it again?

kachelaqa commented 10 years ago

Okay, good. The script now successfully creates the style, and there's no segfault.

kachelaqa commented 10 years ago

I see that this issues has now been marked with needsinfo. But what information is now required?

yuyichao commented 10 years ago

By needsinfo what I mean was the backtrace for ur pyqt crash and I haven't changed it yet.

However, I still cannot reproduce the problem and the pyqt test u provide doesn't seems to show any additional info. I think I would still like to see more debug info for the style loading in order to understand the problem...

kachelaqa commented 10 years ago

Okay, but I don't know what debug info you mean or how to provide it.

yuyichao commented 10 years ago

The problem is so far it doesn't looks like a bug in qtcurve for me and since I cannot reproduce it, I cannot debug it either.

If you would like to debug the problem, the only thing I can think of is to check if the expected paths in qt5 itself are correctly called (require compile ur own qt5-base with the right build parameter and package option) and also if the entry function in QtCurve (QtCurve::StylePlugin::create) is called with the right parameters and returns non NULL.

kachelaqa commented 10 years ago

I think I have sort of solved this now. I say "sort of", because unfortunately I have no idea what I did to fix it. I've experimented with lots of different things over the last week or so, but a couple of days ago it just started working, and has continued to do so. So it looks like this issue can be closed for now.

yuyichao commented 10 years ago

.... k .... Please feel free to reopen it if u see the problem again. Although I think I do need more info in that case ....