mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-03 19:17:02 -05:00 
			
		
		
		
	Improved error reporting, to use qInstallMsgHandler
This commit is contained in:
		
							parent
							
								
									df9c8be1ef
								
							
						
					
					
						commit
						9f3e4f63d9
					
				@ -22,7 +22,8 @@ from editbook import EditBookDialog
 | 
				
			|||||||
from PyQt4.QtCore import Qt, SIGNAL
 | 
					from PyQt4.QtCore import Qt, SIGNAL
 | 
				
			||||||
from PyQt4.Qt import QObject, QThread, QCoreApplication, QEventLoop, QString, QStandardItem, QStandardItemModel, QStatusBar, QVariant, QAbstractTableModel, \
 | 
					from PyQt4.Qt import QObject, QThread, QCoreApplication, QEventLoop, QString, QStandardItem, QStandardItemModel, QStatusBar, QVariant, QAbstractTableModel, \
 | 
				
			||||||
                                   QAbstractItemView, QImage, QPixmap, QIcon, QSize, QMessageBox, QSettings, QFileDialog, QErrorMessage, QDialog, QSpinBox,\
 | 
					                                   QAbstractItemView, QImage, QPixmap, QIcon, QSize, QMessageBox, QSettings, QFileDialog, QErrorMessage, QDialog, QSpinBox,\
 | 
				
			||||||
                                   QPainterPath, QItemDelegate, QPainter, QPen, QColor, QLinearGradient, QBrush, QStyle
 | 
					                                   QPainterPath, QItemDelegate, QPainter, QPen, QColor, QLinearGradient, QBrush, QStyle,\
 | 
				
			||||||
 | 
					                                   qInstallMsgHandler, qDebug, qFatal, qWarning, qCritical
 | 
				
			||||||
from PyQt4 import uic
 | 
					from PyQt4 import uic
 | 
				
			||||||
import sys, re, string, time, os, os.path, traceback, textwrap, zlib
 | 
					import sys, re, string, time, os, os.path, traceback, textwrap, zlib
 | 
				
			||||||
from stat import ST_SIZE
 | 
					from stat import ST_SIZE
 | 
				
			||||||
@ -111,7 +112,6 @@ class LibraryDelegate(QItemDelegate):
 | 
				
			|||||||
  def createEditor(self, parent, option, index):
 | 
					  def createEditor(self, parent, option, index):
 | 
				
			||||||
    if index.column() != 4:
 | 
					    if index.column() != 4:
 | 
				
			||||||
      return QItemDelegate.createEditor(self, parent, option, index)
 | 
					      return QItemDelegate.createEditor(self, parent, option, index)
 | 
				
			||||||
    print "hello"
 | 
					 | 
				
			||||||
    editor = QSpinBox(parent)
 | 
					    editor = QSpinBox(parent)
 | 
				
			||||||
    editor.setSuffix(" stars")
 | 
					    editor.setSuffix(" stars")
 | 
				
			||||||
    editor.setMinimum(0)
 | 
					    editor.setMinimum(0)
 | 
				
			||||||
@ -762,11 +762,15 @@ def main():
 | 
				
			|||||||
    window = QMainWindow()
 | 
					    window = QMainWindow()
 | 
				
			||||||
    def handle_exceptions(t, val, tb):
 | 
					    def handle_exceptions(t, val, tb):
 | 
				
			||||||
      sys.__excepthook__(t, val, tb)
 | 
					      sys.__excepthook__(t, val, tb)
 | 
				
			||||||
      try: QErrorMessage(window).showMessage("There was an unexpected error: <br>"+"<br>".join(traceback.format_exception(t, val, tb)))
 | 
					      try: 
 | 
				
			||||||
 | 
					        qCritical("There was an unexpected error: \n"+"\n".join(traceback.format_exception(t, val, tb)))
 | 
				
			||||||
      except: pass      
 | 
					      except: pass      
 | 
				
			||||||
    sys.excepthook = handle_exceptions
 | 
					    sys.excepthook = handle_exceptions
 | 
				
			||||||
    QCoreApplication.setOrganizationName("KovidsBrain")
 | 
					    QCoreApplication.setOrganizationName("KovidsBrain")
 | 
				
			||||||
    QCoreApplication.setApplicationName("prs500-gui")
 | 
					    QCoreApplication.setApplicationName("SONY Reader")
 | 
				
			||||||
 | 
					    handler = QErrorMessage.qtHandler()
 | 
				
			||||||
 | 
					    handler.resize(600, 400)
 | 
				
			||||||
 | 
					    handler.setModal(True)
 | 
				
			||||||
    gui = MainWindow(window)    
 | 
					    gui = MainWindow(window)    
 | 
				
			||||||
    ret = app.exec_()    
 | 
					    ret = app.exec_()    
 | 
				
			||||||
    return ret
 | 
					    return ret
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user