Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt console crashes on Ubuntu 11.10 #812

Closed
fperez opened this issue Sep 21, 2011 · 21 comments
Closed

Qt console crashes on Ubuntu 11.10 #812

fperez opened this issue Sep 21, 2011 · 21 comments

Comments

@fperez
Copy link
Member

fperez commented Sep 21, 2011

Reported by a user on-list, when starting the qt console with --pylab.

@epatters, does the traceback ring any bells regarding possible Qt api changes you're aware of?

***************************************************************************

IPython post-mortem report

{'commit_hash': '3994edb',
 'commit_source': 'installation',
 'ipython_path': '/usr/local/lib/python2.7/dist-packages/IPython',
 'ipython_version': '0.12.dev',
 'os_name': 'posix',
 'platform': 'Linux-3.0.0-11-generic-i686-with-Ubuntu-11.10-oneiric',
 'sys_executable': '/usr/bin/python',
 'sys_platform': 'linux2',
 'sys_version': '2.7.2+ (default, Aug 16 2011, 07:29:45) \n[GCC 4.6.1]'}

***************************************************************************



***************************************************************************

Crash traceback:

---------------------------------------------------------------------------
TypeError                                    Python 2.7.2+: /usr/bin/python
                                                   Wed Sep 21 02:40:27 2011
A problem occured executing Python code.  Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
/usr/local/lib/python2.7/dist-packages/IPython/frontend/qt/console/console_widget.pyc in sizeHint(self=)
    351 
    352         # Note 1: Despite my best efforts to take the various margins into
    353         # account, the width is still coming out a bit too small, so we include
    354         # a fudge factor of one character here.
    355         # Note 2: QFontMetrics.maxWidth is not used here or anywhere else due
    356         # to a Qt bug on certain Mac OS systems where it returns 0.
    357         width = font_metrics.width(' ') * 81 + margin
    358         width += style.pixelMetric(QtGui.QStyle.PM_ScrollBarExtent)
    359         if self.paging == 'hsplit':
    360             width = width * 2 + splitwidth
    361 
    362         height = font_metrics.height() * 25 + margin
    363         if self.paging == 'vsplit':
    364             height = height * 2 + splitwidth
    365 
--> 366         return QtCore.QSize(width, height)
    367 
    368     #---------------------------------------------------------------------------
    369     # 'ConsoleWidget' public interface
    370     #---------------------------------------------------------------------------
    371 
    372     def can_copy(self):
    373         """ Returns whether text can be copied to the clipboard.
    374         """
    375         return self._control.textCursor().hasSelection()
    376 
    377     def can_cut(self):
    378         """ Returns whether text can be cut to the clipboard.
    379         """
    380         cursor = self._control.textCursor()
    381         return (cursor.hasSelection() and 

TypeError: arguments did not match any overloaded call:
  QSize(): too many arguments
  QSize(int, int): argument 1 has unexpected type 'float'
  QSize(QSize): argument 1 has unexpected type 'float'

***************************************************************************
@ghost
Copy link

ghost commented Sep 21, 2011

Previously sent bug report had a bit more info, so I'm posting it in case it's relevant (this is 0.11 and above is 0.12dev):

    361 
--> 362         return QtCore.QSize(width, height)
        global QtCore.QSize = <class 'PyQt4.QtCore.QSize'>
        width = -4269769018.0
        height = 335.0
    363 
    364     #---------------------------------------------------------------------------
    365     # 'ConsoleWidget' public interface
    366     #---------------------------------------------------------------------------

@ghost
Copy link

ghost commented Sep 21, 2011

Also --pylab switch does not play any role in this bug

@ghost
Copy link

ghost commented Sep 21, 2011

I found out that line c.IPythonWidget.paging = 'hsplit' in ipython_qtconsole_config.py causes this issue

Also running ipython qtconsole --paging=hsplit causes this on my system

ipython qtconsole --paging=vsplit runs fine

@minrk
Copy link
Member

minrk commented Sep 21, 2011

Seems simple enough - QtCore.QSize officially expects int, but sometimes we pass it floats. Some combinations of bindings (e.g. my PySide right now) will just cast floats to int, but we apparently can't rely on it. A simple cast before call should suffice.

@minrk
Copy link
Member

minrk commented Sep 21, 2011

@zetah - if you can confirm that this fixes the issue, I'll merge and close.

@ghost
Copy link

ghost commented Sep 21, 2011

After that running ipython qtconsole --paging=hsplit was without crash. Only that in this situation hsplit wasn't working at all, but default inline split. (Maybe I should remind that IPython documentation about hsplit/vsplit is oposite of how this commands behaves)

I then uncommented line c.IPythonWidget.paging = 'hsplit' in ipython_qtconsole_config.py and IPython crashes again unfortunatelly:

    359         if self.paging == 'hsplit':
    360             width = width * 2 + splitwidth
    361 
    362         height = font_metrics.height() * 25 + margin
    363         if self.paging == 'vsplit':
    364             height = height * 2 + splitwidth
    365 
--> 366         return QtCore.QSize(int(width), int(height))
        global QtCore.QSize = <class 'PyQt4.QtCore.QSize'>
        global int = undefined
        width = -4234948154.0
        height = 335.0
    367 
    368     #---------------------------------------------------------------------------
    369     # 'ConsoleWidget' public interface
    370     #---------------------------------------------------------------------------

Now it crashes also from command line (with --paging=hsplit switch) even if I revert changes in ipython_qtconsole_config.py

BTW above process crashed also Metacity once and this line I get always when running qtconsole:

(python:2506): Gtk-CRITICAL **: IA__gtk_widget_style_get: assertion `GTK_IS_WIDGET (widget)' failed

In the past only ipython internals were shown in terminal when after launching qtconsole

@ghost
Copy link

ghost commented Sep 21, 2011

If I run ipapp.py with arguments qtconsole --paging=hsplit from latest git source, without applied minrk patch with i.e. PyCharm (while trying to debug that negative width float number), everything seems fine and hsplit is working properly

If I go to location of ipapp.py and try with python ipapp.py qtconsole --paging=hsplit this bug emerges, which is logical since it loads already installed IPython modules. But what can be problem

@ghost
Copy link

ghost commented Sep 21, 2011

I'm having hard time trying to figure the problem. I somehow managed to reproduce this with import from installed IPython folder (/usr/local/lib/python2.7/dist-packages/IPython/) in PyCharm, as annotating variables (in console_widget.py) to outside file object did not return any result.

If we look at fperez initial post, at line 357 width has value 496.0, but on next value random large number returned by style.pixelMetric(QtGui.QStyle.PM_ScrollBarExtent). For now, I've been able to extract just this about this object:

style.pixelMetric = <built-in method pixelMetric of QCommonStyle object at 0x969789c>
global QtGui.QStyle.PM_ScrollBarExtent = 9

@ghost
Copy link

ghost commented Sep 21, 2011

OK, it's definitelly this function that return large int for some reason:

style.pixelMetric(QtGui.QStyle.PM_ScrollBarExtent)

@ghost
Copy link

ghost commented Sep 21, 2011

This fixes issue for me (line 358 in console_widget.py ipython 0.12dev):

- width += style.pixelMetric(QtGui.QStyle.PM_ScrollBarExtent)
+ width += QtGui.QStyle.PM_ScrollBarExtent

@ghost
Copy link

ghost commented Sep 21, 2011

:D but it's not very good fix, as splitter now can't be adjusted.

@jenshnielsen
Copy link
Contributor

Note that there is a general problem with qt apps on ubuntu 11.10
that results in:
(python:2901): Gtk-CRITICAL **: IA__gtk_widget_style_get: assertion GTK_IS_WIDGET (widget)' failedin a lot of qt apps. (vlc and others) see: https://bugs.launchpad.net/ubuntu/+source/qt4-x11/+bug/805303 This can be worked around by launching ipython qtconsole like this.LIBOVERLAY_SCROLLBAR=0 ipython qtconsole`

@ghost
Copy link

ghost commented Sep 21, 2011

Thanks for the info. I already downloaded tons of packages just to be able to change default fonts.
Upgrading to 11.10 was really bad idea for me, performance degraded on multiple levels... but can't go back unless clean install again. Which I might do in days to come

@ghost
Copy link

ghost commented Sep 21, 2011

Starting with sudo ipython qtconsole --paging=hsplit runs without issue

@jenshnielsen: Are you running 11.10 also? Can you confirm this issue?

Now if you excuse me I have to catch Tuxedomoon's concert ^_^

@jenshnielsen
Copy link
Contributor

Yes running ipython qtconsole --paging=hsplit does seem to give problems. I have not tried the int() fix from
minrk@7eb81c5
however running the console without the overlay scroll bars by starting the qt console like this
LIBOVERLAY_SCROLLBAR=0 ipython qtconsole fixes the problem for me. So please try this.
I think this fix should make its way into ubuntu 11.10 soon.

@juliantaylor
Copy link
Contributor

the packaged ipython 0.11 (available here: https://launchpad.net/~jtaylor/+archive/ipython-dev/+packages) works fine for me in 11.10
Can you test with that package?

@jenshnielsen
Copy link
Contributor

The problem that I see happens for even simple qt apps in ubuntu 11.10
fx.

#!/usr/bin/python

import sys
from PySide import QtGui

app = QtGui.QApplication(sys.argv)
a = QtGui.QTextEdit()

a.resize(250, 150)
a.setWindowTitle('simple')
a.show()
sys.exit(app.exec_())

gives the same error. It can also be fixed by changing the qt gui style
using qtconfig-qt4 to anything but gtk+

@epatters
Copy link
Contributor

@fperez, sorry, I've been off-line for a few days. It looks like this is an Ubuntu-specific problem, but I'll keep my eye on the issue in case there are some new developments.

@fperez
Copy link
Member Author

fperez commented Sep 21, 2011

Hey,

On Wed, Sep 21, 2011 at 12:36 PM, Evan Patterson
reply@reply.github.com
wrote:

@fperez, sorry, I've been off-line for a few days. It looks like this is an Ubuntu-specific problem, but I'll keep my eye on the issue in case there are some new developments.

No worries, thanks for being on the ball. From the looks of the last
message before yours, it appears to be a generic ubuntu 11.10 bug with
any Qt app, nothing really to do with us. If you concur, feel free to
close this puppy (people can always reopen it if they find evidence
there's something ipython-specific we can do).

@ghost
Copy link

ghost commented Sep 23, 2011

@jenshnielsen: qtconfig setting solved this issue (I forgot to try LIBOVERLAY_SCROLLBAR=0). Now there is small problem with unreadable white font on pale yellow background for tooltips, but I guess I spamed enough IPython issues with irrelevant problems.

Cheers and thanks

@epatters
Copy link
Contributor

No problem. Thanks for confirming the workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants