Skip to content

Commit

Permalink
Set AA_ShareOpenGLContexts attribute, to fix WebEngine warning on Win…
Browse files Browse the repository at this point in the history
…dows

Currently Qt WebEngine complains (as can be seen on appveyor):

  Qt WebEngine seems to be initialized from a plugin. Please set
  Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute before
  constructing QGuiApplication.
  • Loading branch information
mitya57 committed Jan 23, 2017
1 parent 43298d9 commit a641073
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion retext.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from ReText.window import ReTextWindow from ReText.window import ReTextWindow


from PyQt5.QtCore import QFile, QFileInfo, QIODevice, QLibraryInfo, \ from PyQt5.QtCore import QFile, QFileInfo, QIODevice, QLibraryInfo, \
QTextStream, QTranslator QTextStream, QTranslator, Qt
from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QApplication
from PyQt5.QtNetwork import QNetworkProxyFactory from PyQt5.QtNetwork import QNetworkProxyFactory


Expand All @@ -47,6 +47,9 @@ def main():
sys.stdout = open(devnull, 'w') sys.stdout = open(devnull, 'w')
sys.stderr = open('stderr.log', 'w') sys.stderr = open('stderr.log', 'w')


if hasattr(Qt, 'AA_ShareOpenGLContexts'):
# Needed for Qt WebEngine on Windows
QApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
app = QApplication(sys.argv) app = QApplication(sys.argv)
app.setOrganizationName("ReText project") app.setOrganizationName("ReText project")
app.setApplicationName("ReText") app.setApplicationName("ReText")
Expand Down
2 changes: 2 additions & 0 deletions tests/test_editor.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QApplication
from markups import MarkdownMarkup, ReStructuredTextMarkup from markups import MarkdownMarkup, ReStructuredTextMarkup


if hasattr(Qt, 'AA_ShareOpenGLContexts'):
QApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
# Keep a reference so it is not garbage collected # Keep a reference so it is not garbage collected
app = QApplication.instance() or QApplication(sys.argv) app = QApplication.instance() or QApplication(sys.argv)


Expand Down
2 changes: 2 additions & 0 deletions tests/test_settings.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
# only have one QCoreApplication instance for all tests in a process. As # only have one QCoreApplication instance for all tests in a process. As
# other tests need QApplication, we should not create a bare QCoreApplication # other tests need QApplication, we should not create a bare QCoreApplication
# here. Also, keep a reference so it is not garbage collected. # here. Also, keep a reference so it is not garbage collected.
if hasattr(Qt, 'AA_ShareOpenGLContexts'):
QApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
app = QApplication.instance() or QApplication(sys.argv) app = QApplication.instance() or QApplication(sys.argv)


class TestSettings(unittest.TestCase): class TestSettings(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_window.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@


from markups.abstract import ConvertedMarkup from markups.abstract import ConvertedMarkup


from PyQt5.QtCore import pyqtSignal, QObject from PyQt5.QtCore import pyqtSignal, QObject, Qt
from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QApplication
import ReText import ReText
from ReText.window import ReTextWindow from ReText.window import ReTextWindow


defaultEventTimeout = 0.0 defaultEventTimeout = 0.0
path_to_testdata = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'testdata') path_to_testdata = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'testdata')


if hasattr(Qt, 'AA_ShareOpenGLContexts'):
QApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
app = QApplication.instance() or QApplication(sys.argv) app = QApplication.instance() or QApplication(sys.argv)
ReText.initializeDataDirs() ReText.initializeDataDirs()


Expand Down

0 comments on commit a641073

Please sign in to comment.