support for direct debug output

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@16084 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Joost Verburg 2006-11-27 22:56:56 +00:00
parent ee631de7c6
commit 859e121079

View File

@ -5,17 +5,19 @@ Author: Joost Verburg
This will be installed as lyx.exe. This will be installed as lyx.exe.
The application will setup the environment variables and geometry based The application will setup the environment variables and geometry based on
on registry settings and obtain the command line output of lyxc.exe, registry settings and obtain the command line output of lyxc.exe, which can be
which can be shown in case of a crash. Version information and an icon are shown while debugging or in case of a crash. Version information and an icon
also included. are also included.
*/ */
!include "MUI.nsh" !include "MUI.nsh"
!include "LogicLib.nsh" !include "LogicLib.nsh"
!include "FileFunc.nsh" !include "FileFunc.nsh"
!include "StrFunc.nsh"
!insertmacro GetParameters !insertmacro GetParameters
${StrStr}
!include "..\packaging\installer\settings.nsh" ;Version info from installer !include "..\packaging\installer\settings.nsh" ;Version info from installer
@ -23,16 +25,25 @@ Caption "${APP_NAME} ${APP_VERSION}"
OutFile lyx.exe OutFile lyx.exe
BrandingText " " BrandingText " "
;--------------------------------
;Variables
Var Parameters
Var Debug
Var LyXLanguage
Var Geometry
Var ReturnValue
Var ResultText
Var ResultSubText
;-------------------------------- ;--------------------------------
;User interface for debug output ;User interface for debug output
!define MUI_ICON "..\packaging\icons\lyx_32x32.ico" !define MUI_ICON "..\packaging\icons\lyx_32x32.ico"
!define MUI_CUSTOMFUNCTION_GUIINIT InitInterface !define MUI_CUSTOMFUNCTION_GUIINIT InitInterface
!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "Error Information" !define MUI_INSTFILESPAGE_FINISHHEADER_TEXT $ResultText
!define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "See Chapter 3 of the LyX Introduction \ !define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT $ResultSubText
(Help > Introduction) for information about reporting this issue."
!insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English !insertmacro MUI_LANGUAGE English
@ -49,14 +60,6 @@ ShowInstDetails show
!define SM_CXSIZEFRAME 32 !define SM_CXSIZEFRAME 32
!define SM_CYSIZEFRAME 33 !define SM_CYSIZEFRAME 33
;--------------------------------
;Variables
Var Parameters
Var LyXLanguage
Var Geometry
Var ReturnValue
;-------------------------------- ;--------------------------------
;Version information ;Version information
@ -89,11 +92,21 @@ VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "${APP_COPYRIGHT}"
Section -Prepare Section -Prepare
HideWindow ${if} $Debug == ${FALSE}
HideWindow
${endif}
;Command line parameters ;Hide controls we don't need
Call GetParameters FindWindow $R0 "#32770" "" $HWNDPARENT
Pop $Parameters GetDlgItem $R0 $R0 1004
ShowWindow $R0 ${SW_HIDE}
;Debug info
!insertmacro MUI_HEADER_TEXT "Debugging LyX" "The events you have chosen \
are being logged."
SetDetailsPrint textonly
DetailPrint "Debug log:"
SetDetailsPrint listonly
;LyX Language ;LyX Language
!insertmacro GetLyXSetting "Language" $LyXLanguage !insertmacro GetLyXSetting "Language" $LyXLanguage
@ -172,58 +185,88 @@ SectionEnd
Section -Debug Section -Debug
;Check whether something went wrong ${if} $Debug == ${FALSE}
${if} $ReturnValue == "error" ;Check whether something went wrong
;Probably the file does not exist ${if} $ReturnValue == "error"
MessageBox MB_OK|MB_ICONSTOP "Failed to start LyX."
${elseif} $ReturnValue != 0 ;Probably the file does not exist
MessageBox MB_OK|MB_ICONSTOP "Failed to start LyX."
;LyX has crashed ${elseif} $ReturnValue != 0
MessageBox MB_YESNO|MB_ICONSTOP \
"LyX has been closed because of an unexpected situation.$\n\ ;LyX has crashed
This is most likely caused by a flaw in the software.$\n$\n\ MessageBox MB_YESNO|MB_ICONSTOP \
When you open your documents again, you will be able$\n\ "LyX has been closed because of an unexpected situation.$\n\
to restore an emergency save and continue working.$\n$\n\ This is most likely caused by a flaw in the software.$\n$\n\
Would you like to view detailed information about this error?" \ When you open your documents again, you will be able$\n\
IDYES debug IDNO no_debug to restore an emergency save and continue working.$\n$\n\
Would you like to view detailed information about this error?" \
IDYES debug IDNO no_debug
${endif}
no_debug:
Quit
debug:
ShowWindow $R0 ${SW_HIDE}
${endif} ${endif}
no_debug: ${if} $ReturnValue != 0
Quit StrCpy $ResultText "Error Information"
StrCpy $ResultSubText "See Chapter 3 of the LyX Introduction \
(Help > Introduction) for information about reporting this issue."
debug: ${else}
;The interface with debug information will be shown StrCpy $ResultText "Debugging Completed"
StrCpy $ResultSubText "The events you have chosen are logged below."
SetDetailsPrint textonly ${endif}
DetailPrint "The following details are available about the error:"
SetDetailsPrint none
;Hide controls we don't need ${if} $Debug == ${FALSE}
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R0 $R0 1004
ShowWindow $R0 ${SW_HIDE}
;Put the log window on the screen again ;Put the log window on the screen again
Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i 133, i 100, i 0, i 0, i ${SWP_NOSIZE})" Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i 133, i 100, i 0, i 0, i ${SWP_NOSIZE})"
CallInstDLL "$EXEDIR\System.dll" Call CallInstDLL "$EXEDIR\System.dll" Call
BringToFront BringToFront
${endif}
SectionEnd SectionEnd
;-------------------------------- ;--------------------------------
;Functions ;Functions
Function InitInterface Function InitInterface
;Keep the log window outside the screen to ensure that there will be no flickering ;Command line parameters
Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i -32000, i -32000, i 0, i 0, i ${SWP_NOSIZE})" Call GetParameters
CallInstDLL "$EXEDIR\System.dll" Call Pop $Parameters
;Check for debug mode
${StrStr} $R0 $Parameters "-dbg"
${if} $R0 == ""
StrCpy $Debug ${FALSE}
${else}
StrCpy $Debug ${TRUE}
${endif}
${if} $Debug == ${FALSE}
;Keep the log window outside the screen to ensure that there will be no flickering
Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i -32000, i -32000, i 0, i 0, i ${SWP_NOSIZE})"
CallInstDLL "$EXEDIR\System.dll" Call
${endif}
FunctionEnd FunctionEnd