Commit 60166d80 authored by Guillaume Seguin's avatar Guillaume Seguin

Catch openGL failures and avoid flooding console to death

parent 3edac5ed
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
# along with Printrun. If not, see <http://www.gnu.org/licenses/>. # along with Printrun. If not, see <http://www.gnu.org/licenses/>.
from threading import Lock from threading import Lock
import logging
import sys
import traceback
import wx import wx
from wx import glcanvas from wx import glcanvas
...@@ -77,6 +80,8 @@ class wxGLPanel(wx.Panel): ...@@ -77,6 +80,8 @@ class wxGLPanel(wx.Panel):
self.basequat = [0, 0, 0, 1] self.basequat = [0, 0, 0, 1]
self.zoom_factor = 1.0 self.zoom_factor = 1.0
self.gl_broken = False
# bind events # bind events
self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.processEraseBackgroundEvent) self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.processEraseBackgroundEvent)
self.canvas.Bind(wx.EVT_SIZE, self.processSizeEvent) self.canvas.Bind(wx.EVT_SIZE, self.processSizeEvent)
...@@ -104,8 +109,14 @@ class wxGLPanel(wx.Panel): ...@@ -104,8 +109,14 @@ class wxGLPanel(wx.Panel):
'''Process the drawing event.''' '''Process the drawing event.'''
self.canvas.SetCurrent(self.context) self.canvas.SetCurrent(self.context)
self.OnInitGL() if not self.gl_broken:
self.OnDraw() try:
self.OnInitGL()
self.OnDraw()
except pyglet.gl.lib.GLException:
self.gl_broken = True
logging.error(_("OpenGL failed, disabling it:"))
traceback.print_exc(file = sys.stdout)
event.Skip() event.Skip()
def Destroy(self): def Destroy(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment