[gnome-games] Detect exceptions when in OpenGL code and disable 3d mode for next restart (Robert Ancell, Bug #5772
- From: Robert Ancell <rancell src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-games] Detect exceptions when in OpenGL code and disable 3d mode for next restart (Robert Ancell, Bug #5772
- Date: Tue, 8 Sep 2009 03:20:58 +0000 (UTC)
commit dbad49e1f14fe98072a3f8998b795613057e4ecf
Author: Robert Ancell <robert ancell gmail com>
Date: Tue Sep 8 13:20:51 2009 +1000
Detect exceptions when in OpenGL code and disable 3d mode for next restart (Robert Ancell, Bug #577240)
glchess/src/lib/gtkui/chessview.py | 77 ++++++++++++++++++++++--------------
1 files changed, 47 insertions(+), 30 deletions(-)
---
diff --git a/glchess/src/lib/gtkui/chessview.py b/glchess/src/lib/gtkui/chessview.py
index df67952..7768728 100644
--- a/glchess/src/lib/gtkui/chessview.py
+++ b/glchess/src/lib/gtkui/chessview.py
@@ -9,6 +9,7 @@ import gtkui
import glchess.ui
import glchess.chess
import glchess.game
+import glchess.config
# Optionally use OpenGL support
openGLErrors = []
@@ -144,34 +145,42 @@ class GtkViewArea(gtk.DrawingArea):
"""Gtk+ signal"""
self.pixmap = gtk.gdk.Pixmap(widget.window, event.width, event.height)
self.dynamicPixmap = gtk.gdk.Pixmap(widget.window, event.width, event.height)
- self.__startGL()
- if self.view.feedback is not None:
- self.view.feedback.reshape(event.width, event.height)
- self.__endGL()
+ try:
+ self.__startGL()
+ if self.view.feedback is not None:
+ self.view.feedback.reshape(event.width, event.height)
+ self.__endGL()
+ except:
+ glchess.config.set('show_3d', False)
+ raise
def __expose(self, widget, event):
"""Gtk+ signal"""
if self.renderGL:
- self.__startGL()
- if self.__glDrawable is None:
- return
-
- # Get the scene rendered
try:
- if self.view.feedback is not None:
- self.view.feedback.renderGL()
- except OpenGL.GL.GLerror, e:
- print 'Rendering Error: ' + str(e)
- traceback.print_exc(file = sys.stdout)
-
- # Paint this
- if self.__glDrawable.is_double_buffered():
- self.__glDrawable.swap_buffers()
- else:
- OpenGL.GL.glFlush()
+ self.__startGL()
+ if self.__glDrawable is None:
+ return
+
+ # Get the scene rendered
+ try:
+ if self.view.feedback is not None:
+ self.view.feedback.renderGL()
+ except OpenGL.GL.GLerror, e:
+ print 'Rendering Error: ' + str(e)
+ traceback.print_exc(file = sys.stdout)
+
+ # Paint this
+ if self.__glDrawable.is_double_buffered():
+ self.__glDrawable.swap_buffers()
+ else:
+ OpenGL.GL.glFlush()
+
+ self.__endGL()
+ except:
+ glchess.config.set('show_3d', False)
+ raise
- self.__endGL()
-
else:
context = self.pixmap.cairo_create()
if self.view.feedback is not None:
@@ -198,19 +207,27 @@ class GtkViewArea(gtk.DrawingArea):
"""Gtk+ signal"""
if event.button != 1:
return
- self.__startGL()
- if self.view.feedback is not None:
- self.view.feedback.select(event.x, event.y)
- self.__endGL()
+ try:
+ self.__startGL()
+ if self.view.feedback is not None:
+ self.view.feedback.select(event.x, event.y)
+ self.__endGL()
+ except:
+ glchess.config.set('show_3d', False)
+ raise
def __button_release(self, widget, event):
"""Gtk+ signal"""
if event.button != 1:
return
- self.__startGL()
- if self.view.feedback is not None:
- self.view.feedback.deselect(event.x, event.y)
- self.__endGL()
+ try:
+ self.__startGL()
+ if self.view.feedback is not None:
+ self.view.feedback.deselect(event.x, event.y)
+ self.__endGL()
+ except:
+ glchess.config.set('show_3d', False)
+ raise
class GtkView(glchess.ui.ViewController):
"""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]