hbqt_errorsys: proposal for a patch

37 views
Skip to first unread message

Luigi Ferraris

unread,
Jun 22, 2016, 2:10:34 PM6/22/16
to QtContribs
Hi Pritpal,
I would like to propose to you a patch for hbqt_errorsys source.
from line 161 to 166 revised as
   nChoice := hbqt_messageBox( cMsg, NIL, "HBQT Runtime Error", QMessageBox_Critical, oError )
     
   IF nChoice == QMessageBox_Abort
         // this make the difference; break means returns oError object to the recover procedure (CLIPPER)
         // BREAK( oError )
   ELSEIF nChoice == QMessageBox_Retry
      RETURN .T.
   ELSEIF nChoice == QMessageBox_Ignore
      RETURN .F.
   ENDIF

   IF hbqt_IsActiveApplication()
      QApplication():closeAllWindows()
      QApplication():exit( 1 )
   END IF

   ErrorLevel( 1 )
   QUIT

   RETURN .F.


Then the revised static procedure
hbqt_messageBox
STATIC PROCEDURE hbqt_messageBox( cMsg, cInfo, cTitle, nIcon, oError )
   LOCAL oMB
   LOCAL nButtons
   LOCAL nReturn

   IF hbqt_IsActiveApplication()

      hb_default( @cTitle, "Information" )
      hb_default( @nIcon, QMessageBox_Information )
  
      nButtons := QMessageBox_Abort
      IF oError:canRetry
         nButtons := hb_BitOr( nButtons, QMessageBox_Retry )
      ENDIF
      IF oError:canDefault
         nButtons := hb_BitOr( nButtons, QMessageBox_Ignore )
      ENDIF

      WITH OBJECT oMB := QMessageBox()
         :setText( cMsg )
         IF !EMPTY( cInfo )
            :setInformativeText( cInfo )
         END IF
         :setIcon( nIcon )
         :setWindowTitle( cTitle )
         :setStyleSheet( "background-color: white;" )
         :setStandardButtons( nButtons )
         :setDefaultButton( QMessageBox_Abort )
      END WITH
      nReturn := oMB:exec()
      RETURN nReturn
   END IF

   #include "hbtrace.ch"
   HB_TRACE( HB_TR_ALWAYS, hb_ValToExp( cMsg ) )

   RETURN QMessageBox_Abort


In this way, you can have the ability to show Abort, Retry, Ignore. If aborted (default when QApplication is not running) stop your application.

Regards
Luigi
Reply all
Reply to author
Forward
0 new messages