Permalink
Browse files

put segmentation fault in hidden application action

  • Loading branch information...
1 parent b2ab725 commit a349b5f6ffd82c6f0f6d73f63d8338fcce3ae1cc @erikjanss erikjanss committed Mar 2, 2013
Showing with 22 additions and 19 deletions.
  1. +16 −0 camelot/admin/action/application_action.py
  2. +1 −18 camelot/admin/application_admin.py
  3. +5 −1 test/test_action.py
@@ -424,6 +424,22 @@ def model_run( self, model_context ):
unicode(sys.path))
yield action_steps.PrintHtml( html )
+class SegmentationFault( Action ):
+ """Create a segmentation fault by reading null, this is to test
+ the faulthandling functions. this method is triggered by pressing
+ :kbd:`Ctrl-Alt-0` in the GUI"""
+
+ verbose_name = _('Segmentation Fault')
+ shortcut = QtGui.QKeySequence( QtCore.Qt.CTRL+QtCore.Qt.ALT+QtCore.Qt.Key_0 )
+
+ def model_run( self, model_context ):
+ from camelot.view import action_steps
+ ok = yield action_steps.MessageBox( text = 'Are you sure you want to segfault the application',
+ standard_buttons = QtGui.QMessageBox.No | QtGui.QMessageBox.Yes )
+ if ok == QtGui.QMessageBox.Yes:
+ import faulthandler
+ faulthandler._read_null()
+
def structure_to_application_action(structure, application_admin):
"""Convert a python structure to an ApplicationAction
@@ -29,7 +29,7 @@
logger = logging.getLogger('camelot.admin.application_admin')
from PyQt4.QtCore import Qt
-from PyQt4 import QtCore, QtGui
+from PyQt4 import QtCore
from camelot.admin.action import application_action, form_action, list_action
from camelot.core.utils import ugettext_lazy as _
@@ -262,11 +262,6 @@ def create_main_window(self):
gui_context = ApplicationActionGuiContext()
gui_context.admin = self
mainwindow = MainWindow( gui_context )
- shortcut_read_null = QtGui.QShortcut(
- QtGui.QKeySequence( QtCore.Qt.CTRL+QtCore.Qt.ALT+QtCore.Qt.Key_0 ),
- mainwindow
- )
- shortcut_read_null.activated.connect( self.read_null )
return mainwindow
def get_actions(self):
@@ -572,15 +567,3 @@ def get_about(self):
http://www.conceptive.be
</p>
"""%(today.year, license.license_type)
-
- def read_null(self):
- """Create a segmentation fault by reading null, this is to test
- the faulthandling functions. this method is triggered by pressing
- :kbd:`Ctrl-Alt-0` in the GUI"""
- ok = QtGui.QMessageBox.critical( None,
- 'Experimental segfault',
- 'Are you sure you want to segfault the application',
- buttons = QtGui.QMessageBox.No | QtGui.QMessageBox.Yes )
- if ok == QtGui.QMessageBox.Yes:
- import faulthandler
- faulthandler._read_null()
View
@@ -666,7 +666,11 @@ def test_dump_state( self ):
def test_runtime_info( self ):
runtime_info = application_action.RuntimeInfo()
- list( runtime_info.model_run( self.context ) )
+ list( runtime_info.model_run( self.context ) )
+
+ def test_segmentation_fault( self ):
+ segmentation_fault = application_action.SegmentationFault()
+ list( segmentation_fault.model_run( self.context ) )
class DocumentActionsCase( ModelThreadTestCase ):
"""Test the standard document actions.

0 comments on commit a349b5f

Please sign in to comment.