-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
QTextCursor::setPosition: Position 'XX' out of range #2010
Comments
I cannot reproduce this from your description. It could be related to some settings, so if you could post your config file? You can delete settings that point to local paths on your computer. The error itself is probably harmless. Qt sometimes prints errors, and many of them are beyond my control. I'm not sure it is related to highlighting. It is probably related to one of the format/auto-format features instead, which is where the setPosition call is made a lot. |
Here's my novelwriter.conf file:
As created by the AppImage launcher, with reproducible behavior. |
I still can't reproduce it. Neither from AppImage nor source, using your config and following your steps precisely. I do have a different Qt version when running from source, 5.15.8, but in the AppImage it is bundled and should be the same. What remains is to test with the same OS as you. Are you on Ubuntu or Mint? |
I found two Qt bugs that may or may not be related. They too cannot be reproduced, but there could be something related to how Qt handles input methods. See QTBUG-98948 and QTBUG-94720. I cannot find any issue in any use of The warning comes from qtextcursor.cpp#L1129. It checks against its internally recorded length before issuing the warning, and there seem to be some bugs related to how the length is handled for some input methods, like virtual keyboards. I have no idea if that's related, but at least one issue was fixed for 5.15.4, although this one showed up on Android. Until I can reproduce it, I simply don't have any way to tell where it comes from; novelWriter or Qt, |
I'm using Linux Mint 22 Cinnamon. With the fresh config file, I can reproduce this simply by clicking below the bottom-most line in the Editor, right after creating a new project. |
Does it have to be a new project, and if so, which file is open in the editor? I tried on Mint 21.3 (same Qt version) and at least there I could not reproduce it either. Simply clicking in the editor below the last character only triggers the update of the cursor position in the document footer, but there is no call to setPosition made there (it only reads the position) so I'm starting to think this must be internal in the Qt library somewhere. I'm not sure if it is a quirk of the specific versions, the system locale (the document length calculation could be off for some non-ascii letters), or something different. In any event, the message itself is harmless, as I said. The call to setPosition is simply cancelled after the message is printed. I have no way of tracking it down without reproducing it, so I'm stuck at this point. |
This part made me a little curious. I have recently discovered that the QRegularExpression, when wrapped by PyQt, sometime returns garbage matches. I discovered it when testing upgrading novelWriter to Qt 6.4. It produced a number of Unicode errors in the spell checker. The highlighter uses the same regex object as the spell checker. I only suspect the issue is related to Unicode, but I cannot be certain. Python uses fixed 1, 2 or 4 byte encoding depending on the string, while Qt uses UTF 16. The reason I suspect it is that only some strings show the problem, and I bet it's related to whatever encoding Python ends up using. It's possible this is an issue isolated to QRegularExpression in Qt 6.4, or it may be some underlying weakness that shows up other places too. In any case, for the novelWriter 2.6 branch, I've replaced all use of QRegularExpression with the internal Python regex engine. There is even a minor performance improvement as well. I haven't checked the Qt source, but I would expect the syntax highlighter on the Qt side also calls setPosition, and it could be the cause here. Especially since you see an effect on the highlighter too. Would you be able to run the current main branch and see if the issue persists? |
For any new project created with v2.5.1, I'm seeing this error in the console continuously printed as I type in the Editor:
I've been able to reproduce this running from source (using Qt version 5.15.3, Python 3.10.12) and from the AppImage file. With a fresh
$HOME/.config/novelwriter
, it's not as easy to reproduce:One symptom of this seems to be that novelWriter fails to highlight quoted text.
The text was updated successfully, but these errors were encountered: