QTextCursor::setPosition: Position '16786' out of range #1392

Closed
aweinstein opened this Issue Feb 9, 2012 · 17 comments

Projects

None yet

9 participants

@aweinstein

Sometimes (rather infrequently) when using the IPython QtConsole I get the following error message (in the terminal where I launched the QtConsole):

QTextCursor::setPosition: Position '16786' out of range

And an incorrect behavior with the prompt in the QtConsole itself.

I am running Python 2.7.2, IPython 0.12 in an Ubuntu 11.10 machine.

This is a screenshot right after I got the error:

Screenshot

Owner
fperez commented Feb 9, 2012

Great, thanks for filing! By all means post any additional info you may find later. @epatters, does this ring any bells off the top of your head as to what could be going on?

Owner

I think I've seen the 'position out of range' error before when raw_input got messed up (issue #993).

Owner
minrk commented Feb 19, 2012

I see it occasionally, though I've never seen any actual issues with input, so I haven't reported it.

Contributor
anntzer commented Mar 9, 2014

Indeed, I just saw the same issue. When that happens, the next "In[x]:" prompt appears before the previous "Out[x-1]" appeared; the "Out[x-1]" is then printed and the user prompt follows, e.g.

In [1]: f()

In [2]: Out[1]: <result of f()><prompt is here>

I'll report if I manage to reproduce the issue.

@minrk minrk removed the prio-low label Jan 14, 2015
dashesy commented Apr 20, 2015

I get QTextCursor::setPosition: Position '362277' out of range and when it happens I have to close and re-open the window, restarting the kernel does not help.

IPython QtConsole 3.0.0
Python 2.7.8 (default, Nov 10 2014, 08:19:18)
dashesy commented May 6, 2015

I realized when it hangs and prints this error to console, restarting the kernel will not help, but one can still type. If I type say gg and hit enter it does nothing but if I type gg() then hit enter it complains about invalid function but gives me a new line that can work again so it seems input processing is hanging and waiting for something.

dashesy commented May 26, 2015

I noticed this happens almost reproducibly after I use ? to get dir of something like np.unique? then hit q to get to the prompt again, then hit up arrow.

Owner

That didn't reproduce it for me on master (I tried several times).

dashesy commented Jun 22, 2015

after upgrading from 3.0 to 3.2 I do not see this any more

Owner

OK, let's close this for now - we can reopen if we find another reproducible case.

@takluyver takluyver closed this Jun 22, 2015
@minrk minrk modified the milestone: 3.2, wishlist Jul 11, 2015

I could reproduce the problem too, when i use the qtconsole for a long time.
Jupyter QtConsole 4.1.1
Python 2.7.11 |Anaconda 2.4.1 (64-bit)| (default, Dec 7 2015, 14:10:42) [MSC v.1500 64 bit (AMD64)]

slehar commented Feb 10, 2016

I have found a test case that reproduces the problem almost reliably, hopefully this might help us converge on the problem. It is a program that tests indexed images, reading their pixel values and printing to the IPython terminal. The source code and image follow.

QTextCursorError.py.gz

burrindx

To reproduce the problem:

[1]: Run the program, move your cursor around in the image, observe (x,y) coordinates printed continuously on the IPython command line.

[2]: Move the image window to a different location

[3]: In the IPython console type some text, preferably meaningful text like "dir()"

[4]: Move your cursor around in the image again.

Repeat steps 2-4 and eventually step 4 will produce the error

QTextCursor::setPosition: Position '13547' out of range
QTextCursor::setPosition: Position '13619' out of range
QTextCursor::setPosition: Position '13691' out of range
QTextCursor::setPosition: Position '13763' out of range
QTextCursor::setPosition: Position '13811' out of range
QTextCursor::setPosition: Position '13835' out of range
QTextCursor::setPosition: Position '13907' out of range
...

whenever you move the mouse in the image.

So the problem seems to involve a loss of synch between the window coordinates or something.

Hope this is helpful.

dashesy commented Feb 29, 2016

@slehar can you also attach BurrIndx.png. Or is it the png beneath the attachment?

dashesy commented Feb 29, 2016

Ok I renamed the png to BurrIndx.png. I tested it on Linux. While I do not see the QTextCursor::setPosition: Position '13547' out of range warnings any more I see this when I issue ls (but not dir()):

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib64/python2.7/lib-tk/Tkinter.py", line 1536, in __call__
    return self.func(*args)
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 383, in motion_notify_event
    FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=event)
  File "/usr/lib64/python2.7/site-packages/matplotlib/backend_bases.py", line 1936, in motion_notify_event
    self.callbacks.process(s, event)
  File "/usr/lib64/python2.7/site-packages/matplotlib/cbook.py", line 540, in process
    proxy(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/matplotlib/cbook.py", line 415, in __call__
    return mtd(*args, **kwargs)
  File "/home/dashesy/Downloads/QTextCursorError.py", line 25, in onmotion
    print 'x=%3d, y=%3d, pixel=%3d'%(imgX, imgY, int(burrIndx[imgY, imgX]))
IndexError: index 25 is out of bounds for axis 0 with size 24

This is IPython 2.4.1 I am going to test on Jupyter now. What is your version?

It seems the event handler may call the callback with negative numbers or numbers above the size of the image.

dashesy commented Feb 29, 2016

Ok I see the errors with Jupyter on master branch so it is a good reproducible case:

QTextCursor::setPosition: Position '32400' out of range
Jupyter QtConsole 4.3.0.dev
IPython 4.1.1 
Python 2.7.10 

If one runs %pylab to have the image it occurs more, but even without %pylab it can be seen just click on few places outside the image. It happens any time the image is occluded with the terminal for example.

slehar commented Mar 1, 2016

Sorry Dashesy, didn't notice your reply (shouldn't I get an email when people respond to my post?)
Yes I included BurrIndx.png beneath the attachment (tiny image for testing purposes)
My versions are:
Spyder 2.3.7
Python 2.7.10 64bits, Qt 4.8.7, PyQt4 (API v2) 4.11.4 on Darwin
Let me know if I can be of further help.

I'm attempting a fix in jupyter/qtconsole#145

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