-
Notifications
You must be signed in to change notification settings - Fork 13
/
dsvedit.rb
56 lines (42 loc) · 1.21 KB
/
dsvedit.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
DEBUG = true
require 'logger'
begin
require 'Qt'
require 'fileutils'
require 'yaml'
require 'pathname'
require_relative 'dsvlib'
require_relative 'version'
require_relative 'dsvedit/main_window'
if defined?(Ocra)
exit
end
Dir.chdir(File.dirname(__FILE__))
$qApp = Qt::Application.new(ARGV)
window = DSVEdit.new
begin
$qApp.exec
rescue StandardError => e
window.save_settings()
if window.game && window.game.fs && window.game.fs.has_uncommitted_changes?
backup_dir = File.join(window.game.folder, "_dsvedit_backup")
window.game.fs.commit_changes(base_directory = backup_dir)
puts "Wrote backup of unsaved files to #{backup_dir}"
end
raise e
end
rescue SystemExit, Interrupt
raise
rescue Exception => e
logger = Logger.new("crashlog.txt")
logger.error e
if !DEBUG && defined?(Qt::Application)
$qApp = Qt::Application.new(ARGV)
msg = "DSVEdit has crashed.\nPlease report this bug with a screenshot of this error:\n\n"
msg << "Error: #{e.class.name}: #{e.message}\n\n"
msg << e.backtrace.join("\n")
Qt::MessageBox.critical(window, "Error", msg)
end
puts "Error: #{e.class.name}: #{e.message}"
puts e.backtrace
end