Commit a836e00

Nick committed on
Add custom exception handler, fix file not open bug
commit a836e00e404e6e9abb955b61f379d843e96c4044 parent b51292a
4 changed files +75−65
ModifiedGBEmu.lpr +5−0
@@ -67,6 +67,11 @@ begin
67 ExitProc := @WindowsExitProc; 67 ExitProc := @WindowsExitProc;
68 {$endif} 68 {$endif}
69 69
70 {$ifdef PRODUCTION}
71 Assign(Output, 'output.log');
72 Rewrite(Output);
73 {$endif}
74
70 Application.Scaled:=True; 75 Application.Scaled:=True;
71 Application.Title:='hUGETracker'; 76 Application.Title:='hUGETracker';
72 Application.Initialize; 77 Application.Initialize;
Modifiedcodegen.pas +0−30
@@ -632,36 +632,6 @@ begin
632 finally 632 finally
633 Proc.Free; 633 Proc.Free;
634 end; 634 end;
635
636 {AssemblyError:
637 Result := False;
638 OutSL.LoadFromStream(Proc.Output);
639
640 if OutSL.Text.Contains('routine') then
641 MessageDlg(
642 'Error!',
643 'There was an error assembling the song for playback.' + LineEnding +
644 LineEnding + Proc.Executable + ' output:' + LineEnding + OutSL.Text,
645 mtError,
646 [mbOK],
647 0)
648 else
649 begin
650 MessageDlg(
651 'Error!',
652 'There was an error assembling the song for playback.' + LineEnding +
653 LineEnding + Proc.Executable + ' output:' + LineEnding + OutSL.Text +
654 LineEnding + LineEnding +
655 'Please report this issue on the hUGETracker GitHub issues page, and ' +
656 'post your song file!',
657 mtError,
658 [mbOK],
659 0);
660
661 {$ifdef PRODUCTION}
662 OpenURL('https://github.com/SuperDisk/hUGETracker/issues');
663 {$endif}
664 end;}
665 end; 635 end;
666 636
667 { EAssemblyException } 637 { EAssemblyException }
Modifiedtracker.lfm +34−35
@@ -18,7 +18,7 @@ object frmTracker: TfrmTracker
18 OnShow = FormShow 18 OnShow = FormShow
19 Position = poDefault 19 Position = poDefault
20 ShowHint = True 20 ShowHint = True
21 LCLVersion = '2.0.9.0' 21 LCLVersion = '2.0.11.0'
22 object TreeView1: TTreeView 22 object TreeView1: TTreeView
23 Left = 0 23 Left = 0
24 Height = 913 24 Height = 913
@@ -62,15 +62,15 @@ object frmTracker: TfrmTracker
62 Height = 913 62 Height = 913
63 Top = 0 63 Top = 0
64 Width = 1809 64 Width = 1809
65 ActivePage = InstrumentTabSheet 65 ActivePage = GeneralTabSheet
66 Align = alClient 66 Align = alClient
67 ParentFont = False 67 ParentFont = False
68 TabIndex = 2 68 TabIndex = 0
69 TabOrder = 0 69 TabOrder = 0
70 object GeneralTabSheet: TTabSheet 70 object GeneralTabSheet: TTabSheet
71 Caption = 'General' 71 Caption = 'General'
72 ClientHeight = 483 72 ClientHeight = 870
73 ClientWidth = 1063 73 ClientWidth = 1801
74 ParentFont = False 74 ParentFont = False
75 object SongInformationGroupbox: TGroupBox 75 object SongInformationGroupbox: TGroupBox
76 Left = 14 76 Left = 14
@@ -84,25 +84,25 @@ object frmTracker: TfrmTracker
84 TabOrder = 0 84 TabOrder = 0
85 object Label15: TLabel 85 object Label15: TLabel
86 Left = 14 86 Left = 14
87 Height = 15 87 Height = 30
88 Top = 28 88 Top = 28
89 Width = 27 89 Width = 47
90 Caption = 'Song' 90 Caption = 'Song'
91 ParentColor = False 91 ParentColor = False
92 ParentFont = False 92 ParentFont = False
93 end 93 end
94 object Label16: TLabel 94 object Label16: TLabel
95 Left = 12 95 Left = 12
96 Height = 15 96 Height = 30
97 Top = 84 97 Top = 84
98 Width = 28 98 Width = 49
99 Caption = 'Artist' 99 Caption = 'Artist'
100 ParentColor = False 100 ParentColor = False
101 ParentFont = False 101 ParentFont = False
102 end 102 end
103 object SongEdit: TEdit 103 object SongEdit: TEdit
104 Left = 98 104 Left = 98
105 Height = 23 105 Height = 38
106 Hint = 'The name of your composition' 106 Hint = 'The name of your composition'
107 Top = 14 107 Top = 14
108 Width = 378 108 Width = 378
@@ -112,7 +112,7 @@ object frmTracker: TfrmTracker
112 end 112 end
113 object ArtistEdit: TEdit 113 object ArtistEdit: TEdit
114 Left = 98 114 Left = 98
115 Height = 23 115 Height = 38
116 Hint = 'Your name or handle' 116 Hint = 'Your name or handle'
117 Top = 70 117 Top = 70
118 Width = 378 118 Width = 378
@@ -122,16 +122,16 @@ object frmTracker: TfrmTracker
122 end 122 end
123 object Label21: TLabel 123 object Label21: TLabel
124 Left = 14 124 Left = 14
125 Height = 15 125 Height = 30
126 Top = 136 126 Top = 136
127 Width = 114 127 Width = 197
128 Caption = 'Tempo (ticks per row)' 128 Caption = 'Tempo (ticks per row)'
129 ParentColor = False 129 ParentColor = False
130 ParentFont = False 130 ParentFont = False
131 end 131 end
132 object TicksPerRowSpinEdit: TSpinEdit 132 object TicksPerRowSpinEdit: TSpinEdit
133 Left = 233 133 Left = 233
134 Height = 23 134 Height = 38
135 Hint = 'How many ticks should happen before the row changes. Higher means slower' 135 Hint = 'How many ticks should happen before the row changes. Higher means slower'
136 Top = 128 136 Top = 128
137 Width = 88 137 Width = 88
@@ -212,12 +212,11 @@ object frmTracker: TfrmTracker
212 Height = 815 212 Height = 815
213 Top = 53 213 Top = 53
214 Width = 1407 214 Width = 1407
215 HorzScrollBar.Increment = 3 215 HorzScrollBar.Increment = 5
216 HorzScrollBar.Page = 32 216 HorzScrollBar.Page = 56
217 HorzScrollBar.Smooth = True 217 HorzScrollBar.Smooth = True
218 HorzScrollBar.Tracking = True 218 HorzScrollBar.Tracking = True
219 VertScrollBar.Increment = 5 219 VertScrollBar.Page = 88
220 VertScrollBar.Page = 50
221 VertScrollBar.Smooth = True 220 VertScrollBar.Smooth = True
222 VertScrollBar.Tracking = True 221 VertScrollBar.Tracking = True
223 Align = alClient 222 Align = alClient
@@ -1725,7 +1724,7 @@ object frmTracker: TfrmTracker
1725 ParentShowHint = False 1724 ParentShowHint = False
1726 end 1725 end
1727 object PanicToolButton: TToolButton 1726 object PanicToolButton: TToolButton
1728 Left = 851 1727 Left = 839
1729 Hint = 'Stops all sound output' 1728 Hint = 'Stops all sound output'
1730 Top = 0 1729 Top = 0
1731 AutoSize = True 1730 AutoSize = True
@@ -1736,17 +1735,17 @@ object frmTracker: TfrmTracker
1736 ShowHint = True 1735 ShowHint = True
1737 end 1736 end
1738 object ToolButton2: TToolButton 1737 object ToolButton2: TToolButton
1739 Left = 221 1738 Left = 217
1740 Top = 0 1739 Top = 0
1741 Action = PlayCursorAction 1740 Action = PlayCursorAction
1742 end 1741 end
1743 object ToolButton4: TToolButton 1742 object ToolButton4: TToolButton
1744 Left = 331 1743 Left = 327
1745 Top = 0 1744 Top = 0
1746 Action = StopAction 1745 Action = StopAction
1747 end 1746 end
1748 object ExportGBButton: TToolButton 1747 object ExportGBButton: TToolButton
1749 Left = 442 1748 Left = 434
1750 Hint = 'Export the song as a standalone ROM' 1749 Hint = 'Export the song as a standalone ROM'
1751 Top = 0 1750 Top = 0
1752 AutoSize = True 1751 AutoSize = True
@@ -1762,21 +1761,21 @@ object frmTracker: TfrmTracker
1762 Style = tbsDivider 1761 Style = tbsDivider
1763 end 1762 end
1764 object ToolButton6: TToolButton 1763 object ToolButton6: TToolButton
1765 Left = 433 1764 Left = 429
1766 Height = 39 1765 Height = 39
1767 Top = 0 1766 Top = 0
1768 Caption = 'ToolButton6' 1767 Caption = 'ToolButton6'
1769 Style = tbsDivider 1768 Style = tbsDivider
1770 end 1769 end
1771 object ToolButton7: TToolButton 1770 object ToolButton7: TToolButton
1772 Left = 1775 1771 Left = 1757
1773 Height = 39 1772 Height = 39
1774 Top = 0 1773 Top = 0
1775 Caption = 'ToolButton7' 1774 Caption = 'ToolButton7'
1776 Style = tbsSeparator 1775 Style = tbsSeparator
1777 end 1776 end
1778 object OctaveSpinEdit: TSpinEdit 1777 object OctaveSpinEdit: TSpinEdit
1779 Left = 1016 1778 Left = 998
1780 Height = 38 1779 Height = 38
1781 Hint = 'The octave offset for entering new notes' 1780 Hint = 'The octave offset for entering new notes'
1782 Top = 0 1781 Top = 0
@@ -1787,14 +1786,14 @@ object frmTracker: TfrmTracker
1787 TabOrder = 0 1786 TabOrder = 0
1788 end 1787 end
1789 object ToolButton9: TToolButton 1788 object ToolButton9: TToolButton
1790 Left = 927 1789 Left = 915
1791 Height = 39 1790 Height = 39
1792 Top = 0 1791 Top = 0
1793 Caption = 'ToolButton9' 1792 Caption = 'ToolButton9'
1794 Style = tbsSeparator 1793 Style = tbsSeparator
1795 end 1794 end
1796 object Label22: TLabel 1795 object Label22: TLabel
1797 Left = 941 1796 Left = 923
1798 Height = 39 1797 Height = 39
1799 Top = 0 1798 Top = 0
1800 Width = 75 1799 Width = 75
@@ -1805,7 +1804,7 @@ object frmTracker: TfrmTracker
1805 ParentFont = False 1804 ParentFont = False
1806 end 1805 end
1807 object Label23: TLabel 1806 object Label23: TLabel
1808 Left = 1130 1807 Left = 1112
1809 Height = 39 1808 Height = 39
1810 Top = 0 1809 Top = 0
1811 Width = 122 1810 Width = 122
@@ -1816,7 +1815,7 @@ object frmTracker: TfrmTracker
1816 ParentFont = False 1815 ParentFont = False
1817 end 1816 end
1818 object InstrumentComboBox: TComboBox 1817 object InstrumentComboBox: TComboBox
1819 Left = 1252 1818 Left = 1234
1820 Height = 38 1819 Height = 38
1821 Hint = 'The selected instrument for new notes' 1820 Hint = 'The selected instrument for new notes'
1822 Top = 0 1821 Top = 0
@@ -1834,7 +1833,7 @@ object frmTracker: TfrmTracker
1834 Text = '(no instrument)' 1833 Text = '(no instrument)'
1835 end 1834 end
1836 object Label24: TLabel 1835 object Label24: TLabel
1837 Left = 1626 1836 Left = 1608
1838 Height = 39 1837 Height = 39
1839 Top = 0 1838 Top = 0
1840 Width = 61 1839 Width = 61
@@ -1845,7 +1844,7 @@ object frmTracker: TfrmTracker
1845 ParentFont = False 1844 ParentFont = False
1846 end 1845 end
1847 object StepSpinEdit: TSpinEdit 1846 object StepSpinEdit: TSpinEdit
1848 Left = 1687 1847 Left = 1669
1849 Height = 38 1848 Height = 38
1850 Hint = 'How many rows to step down after entering a new note' 1849 Hint = 'How many rows to step down after entering a new note'
1851 Top = 0 1850 Top = 0
@@ -1856,12 +1855,12 @@ object frmTracker: TfrmTracker
1856 TabOrder = 2 1855 TabOrder = 2
1857 end 1856 end
1858 object ToolButton3: TToolButton 1857 object ToolButton3: TToolButton
1859 Left = 129 1858 Left = 125
1860 Top = 0 1859 Top = 0
1861 Action = PlayStartAction 1860 Action = PlayStartAction
1862 end 1861 end
1863 object ExportGBSButton: TToolButton 1862 object ExportGBSButton: TToolButton
1864 Left = 564 1863 Left = 556
1865 Hint = 'Export the song as a GBS soundtrack' 1864 Hint = 'Export the song as a GBS soundtrack'
1866 Top = 0 1865 Top = 0
1867 Caption = 'Export .GBS' 1866 Caption = 'Export .GBS'
@@ -1869,14 +1868,14 @@ object frmTracker: TfrmTracker
1869 OnClick = ExportGBSButtonClick 1868 OnClick = ExportGBSButtonClick
1870 end 1869 end
1871 object ToolButton5: TToolButton 1870 object ToolButton5: TToolButton
1872 Left = 842 1871 Left = 834
1873 Height = 39 1872 Height = 39
1874 Top = 0 1873 Top = 0
1875 Caption = 'ToolButton5' 1874 Caption = 'ToolButton5'
1876 Style = tbsDivider 1875 Style = tbsDivider
1877 end 1876 end
1878 object ToolButton10: TToolButton 1877 object ToolButton10: TToolButton
1879 Left = 697 1878 Left = 689
1880 Hint = 'Export the song as WAV or MP3' 1879 Hint = 'Export the song as WAV or MP3'
1881 Top = 0 1880 Top = 0
1882 Caption = 'Render Song' 1881 Caption = 'Render Song'
Modifiedtracker.pas +36−0
@@ -437,6 +437,8 @@ type
437 437
438 InFDCallback: Boolean; 438 InFDCallback: Boolean;
439 439
440 procedure CustomExceptionHandler(Sender: TObject; E: Exception);
441
440 procedure ChangeToSquare; 442 procedure ChangeToSquare;
441 procedure ChangeToWave; 443 procedure ChangeToWave;
442 procedure ChangeToNoise; 444 procedure ChangeToNoise;
@@ -1202,6 +1204,36 @@ begin
1202 CurrentInstrument^.OutputLevel := WaveVolumeCombobox.ItemIndex; 1204 CurrentInstrument^.OutputLevel := WaveVolumeCombobox.ItemIndex;
1203 end; 1205 end;
1204 1206
1207 procedure TfrmTracker.CustomExceptionHandler(Sender: TObject; E: Exception);
1208 var
1209 Stream: TStream;
1210 G: TGUID;
1211 OutName: String;
1212 begin
1213 CreateGuid(G);
1214 OutName := 'BACKUP_'+GUIDToString(G)+'.uge';
1215
1216 stream := TFileStream.Create(OutName, fmCreate);
1217 try
1218 WriteSongToStream(stream, Song);
1219 finally
1220 stream.Free;
1221 end;
1222
1223 MessageDlg('Error',
1224 'An exception in hUGETracker has occured.' + LineEnding +
1225 'Your song has been backed up to the hUGETracker folder, so don''t worry!' + LineEnding+LineEnding+
1226 'Please report this issue on GitHub, or contact me directly via Discord or Email.'+LineEnding+LineEnding+
1227 'Email: [email protected]'+LineEnding+
1228 'Discord: SuperDisk#5726'+LineEnding+LineEnding+
1229 'The error is: '+E.ClassName+' with message '+E.Message+LineEnding+LineEnding+
1230 'Thank you.',
1231 mtError,
1232 [mbOK], 0);
1233
1234 Application.Terminate;
1235 end;
1236
1205 procedure TfrmTracker.PaintBox1Paint(Sender: TObject); 1237 procedure TfrmTracker.PaintBox1Paint(Sender: TObject);
1206 begin 1238 begin
1207 PaintBox1.Canvas.Brush.Color := clBlack; 1239 PaintBox1.Canvas.Brush.Color := clBlack;
@@ -1292,6 +1324,10 @@ begin
1292 Application.Terminate; 1324 Application.Terminate;
1293 end; 1325 end;
1294 1326
1327 {$ifdef PRODUCTION}
1328 Application.OnException := @CustomExceptionHandler;
1329 {$endif}
1330
1295 VisualizerBuffer := TBGRABitmap.Create(Duty1Visualizer.Width, Duty1Visualizer.Height); 1331 VisualizerBuffer := TBGRABitmap.Create(Duty1Visualizer.Width, Duty1Visualizer.Height);
1296 1332
1297 PreviewingInstrument := -1; 1333 PreviewingInstrument := -1;