Skip to content
This repository

Qt console crashes on Ubuntu 11.10 #812

Closed
fperez opened this Issue September 20, 2011 · 21 comments

5 participants

Fernando Perez Evan Patterson Min RK Jens H Nielsen Julian Taylor
Fernando Perez
Owner

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'

***************************************************************************
Deleted user

The content you are editing has changed. Reload the page and try again.

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     #---------------------------------------------------------------------------
Sending Request…

Attach images by dragging & dropping or selecting them. Octocat-spinner-32 Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Deleted user

The content you are editing has changed. Reload the page and try again.

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

Sending Request…

Attach images by dragging & dropping or selecting them. Octocat-spinner-32 Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Deleted user

The content you are editing has changed. Reload the page and try again.

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

Sending Request…

Attach images by dragging & dropping or selecting them. Octocat-spinner-32 Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Min RK
Owner

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.

Min RK minrk referenced this issue from a commit September 20, 2011
Commit has since been removed from the repository and is no longer available.
Min RK
Owner

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

Deleted user

The content you are editing has changed. Reload the page and try again.

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

Sending Request…

Attach images by dragging & dropping or selecting them. Octocat-spinner-32 Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Deleted user

The content you are editing has changed. Reload the page and try again.

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

Sending Request…

Attach images by dragging & dropping or selecting them. Octocat-spinner-32 Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Deleted user

The content you are editing has changed. Reload the page and try again.

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
Sending Request…

Attach images by dragging & dropping or selecting them. Octocat-spinner-32 Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Deleted user

The content you are editing has changed. Reload the page and try again.

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

style.pixelMetric(QtGui.QStyle.PM_ScrollBarExtent)

Sending Request…

Attach images by dragging & dropping or selecting them. Octocat-spinner-32 Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Deleted user

The content you are editing has changed. Reload the page and try again.

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
Sending Request…

Attach images by dragging & dropping or selecting them. Octocat-spinner-32 Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Deleted user

The content you are editing has changed. Reload the page and try again.

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

Sending Request…

Attach images by dragging & dropping or selecting them. Octocat-spinner-32 Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Jens H Nielsen

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)' failed
in 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

Deleted user

The content you are editing has changed. Reload the page and try again.

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

Sending Request…

Attach images by dragging & dropping or selecting them. Octocat-spinner-32 Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Deleted user

The content you are editing has changed. Reload the page and try again.

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 ^_^

Sending Request…

Attach images by dragging & dropping or selecting them. Octocat-spinner-32 Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Jens H Nielsen

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.

Julian Taylor
Collaborator

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?

Jens H Nielsen

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+

Evan Patterson
Collaborator

@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.

Fernando Perez
Owner
Deleted user

The content you are editing has changed. Reload the page and try again.

@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

Sending Request…

Attach images by dragging & dropping or selecting them. Octocat-spinner-32 Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Evan Patterson
Collaborator

No problem. Thanks for confirming the workaround.

Evan Patterson epatters closed this September 23, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.