[QScintilla] Bug copying text on QScintilla

BPL spscener84 at gmail.com
Sat Jul 20 12:25:22 BST 2019


Phil,

Sorry for the delay, I'd forgotten to confirm your context manager "hack"
had fixed the issue. That said, wouldn't be possible to have a proper fix
without using a context manager at all? That'd be a much better clean&ideal
solution so all existing pyqt application would benefit from the bug fix
without changing any code, plus... in pyside2 the bug doesn't exist when
using the normal way of creating the app instance, check this one out:

USE_PYQT = True

if USE_PYQT:
    from PyQt5.Qt import *
else:
    from PySide2.QtGui import *
    from PySide2.QtCore import *
    from PySide2.QtWidgets import *

if __name__ == '__main__':
    app = QApplication([])
    w = QPlainTextEdit()
    w.setPlainText("hello world")
    w.show()
    app.exec_()

Regards

On Tue, Jun 18, 2019 at 7:16 PM Scener Spanish <spscener84 at gmail.com> wrote:

> Phil, that workaround sounds great!
>
> When I'm back home I'll check it out to confirm it'll work with this and
> the mcve provided in the other thread in pyqt mailing list. In the other
> thread you'll see when using pyside you don't need explicitely delete the
> app.
>
> In any case, my main goal was making sure you would become aware of this
> one :)
>
> Thanks for looking into it
>
> El mar., 18 jun. 2019 18:59, Phil Thompson <phil at riverbankcomputing.com>
> escribió:
>
>> On 18/06/2019 15:02, Scener Spanish wrote:
>> > Let's continue this conversation on my other message related to this in
>> > the
>> > pyqt mailing list. Also, make sure you don't open the viewer till
>> > you've
>> > closed the app... In fact, you don't even need a clip viewer, the
>> > information won't be copied properly. Did you check on win7 or higher?
>> >
>> > Thanks
>> >
>> > El mar., 18 jun. 2019 15:58, Phil Thompson
>> > <phil at riverbankcomputing.com>
>> > escribió:
>> >
>> >> On 14/06/2019 12:13, Scener Spanish wrote:
>> >> > I forgot to add the line `w.selectAll()` after w.show() in my
>> previous
>> >> > snippet... btw, it'd be great having a github repo to report
>> >> > pyqt/qscintilla issues... mailing lists
>> >> > was a good thing in the 90s, not anymore ;D
>> >> >
>> >> > On Fri, Jun 14, 2019 at 1:05 PM Scener Spanish <spscener84 at gmail.com
>> >
>> >> > wrote:
>> >> >
>> >> >> Hi, consider this snippet:
>> >> >>
>> >> >> from PyQt5.Qt import *
>> >> >> from PyQt5.Qsci import QsciScintilla
>> >> >>
>> >> >>
>> >> >> if __name__ == '__main__':
>> >> >>     app = QApplication([])
>> >> >>     w = QsciScintilla()
>> >> >>     w.setText("hello world")
>> >> >>     w.show()
>> >> >>     app.exec_()
>> >> >>
>> >> >> *Test1) *Run it, press ctrl+c, close the window and then open your
>> >> >> system
>> >> >> clipboard viewer... for some reason on windows7 the is broken,
>> you'll
>> >> >> binary content --> this
>> >> >> <
>> >>
>> https://dl.dropboxusercontent.com/s/gtf9cgg1cygbre4/clipbrd_2019-06-14_12-56-37.png
>> >
>> >>
>> >> >> . That
>> >> >> means you won't be able to paste the content on a text editor.
>> >> >>
>> >> >> *Test2) *Run it, press ctrl+c and then open your system clipboard
>> >> >> viewer,
>> >> >> in this case you'll be able to see the copied content correctly,
>> like
>> >> >> this
>> >> >> <
>> >>
>> https://dl.dropboxusercontent.com/s/8xq5riznnxs07cg/clipbrd_2019-06-14_12-59-06.png
>> >> >
>> >> >> .
>> >> >>
>> >> >> This issue has really annoyed me in the past many times but I didn't
>> >> >> know
>> >> >> how to reproduce it or what was the reason why the content I'd
>> copied
>> >> >> from
>> >> >> my app couldn't be pasted anymore
>> >> >>
>> >> >> *Requirements:*
>> >> >>
>> >> >> windows 7 ultimate
>> >> >> Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32
>> >> >> bit
>> >> >> (Intel)] on win32
>> >> >>
>> >> >> QScintilla==2.11.2.dev1905151033
>> >> >> PyQt5==5.12.2
>> >> >> PyQt5-sip==4.19.17
>> >>
>> >> There is no system clipboard viewer on Windows. With...
>> >>
>> >> http://www.freeclipboardviewer.com
>> >>
>> >> ...it seems to work fine.
>> >>
>> >> Phil
>>
>> Ok I can now reproduce the problem. It also happens with C++ when the
>> QApplication is created on the heap and not explicitly destroyed.
>>
>> The workaround in your test is to 'del app' at the end of the script.
>>
>> Tonight's PyQt snapshot adds support for using QCoreApplication (and
>> sub-classes) as a context manager which calls the C++ dtor when exiting
>> the context. So...
>>
>> with QApplication([]) as app:
>>      ....
>>      app->exec()
>>
>> Phil
>>
>> Phil
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/qscintilla/attachments/20190720/13d42fa2/attachment.html>


More information about the QScintilla mailing list