Skip to content

Commit c1c4d3e

Browse files
committed
Add some safety to file saving
1 parent 55654b7 commit c1c4d3e

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

Types/FileIO.bmx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Type FileIO
7070

7171
Method SaveFile:Int(pixmapToSave:TPixmap)
7272
Local filename:String = RequestFile("Save graphic output", m_FileFilters, True)
73-
If CheckValidExportFileName(filename) Then
73+
If pixmapToSave <> Null And CheckValidExportFileName(filename) Then
7474
Local saveSuccess:Int = True
7575
If m_SaveAsIndexed Then
7676
Select m_IndexedFileType
@@ -97,7 +97,7 @@ Type FileIO
9797

9898
Method SaveFileAsFrames:Int(pixmapToSave:TPixmap[,], frameCount:Int)
9999
Local filename:String = RequestFile("Save graphic output", Null, True) 'No file extensions here, we add them later manually otherwise exported file name is messed up
100-
If CheckValidExportFileName(filename) Then
100+
If pixmapToSave <> Null And CheckValidExportFileName(filename) Then
101101
Local saveSuccess:Int = True
102102
For Local row:Int = 0 To 3
103103
Local rowName:String 'Name the rows - by default: ArmFG, ArmBG, LegFG, LegBG in this order

Types/GraphicsOutput.bmx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ Type GraphicsOutput
122122
Method GrabOutputForSaving:TPixmap()
123123
If m_SourceImage = Null Then
124124
Notify("Nothing to save!", False)
125+
Return Null
125126
Else
126127
ChangeBackgroundColor(m_Magenta)
127128
Draw()
@@ -135,6 +136,7 @@ Type GraphicsOutput
135136
Method GrabOutputFramesForSaving:TPixmap[,]()
136137
If m_SourceImage = Null Then
137138
Notify("Nothing to save!", False)
139+
Return Null
138140
Else
139141
ChangeBackgroundColor(m_Magenta)
140142
Draw()

Types/UserInterface.bmx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Type UserInterface
8888

8989
m_LeftColumn = CreatePanel(0, 0, m_LeftColumnSize[0], m_LeftColumnSize[1], m_MainWindow, Null)
9090
SetGadgetLayout(m_LeftColumn, 0, m_LeftColumnSize[0], 0, m_LeftColumnSize[1])
91+
SetGadgetSensitivity(m_LeftColumn, SENSITIZE_KEYS)
9192

9293
Local horizMargin:Int = 5
9394
Local vertMargin:Int = 10
@@ -99,13 +100,15 @@ Type UserInterface
99100

100101
m_ButtonPanel = CreatePanel(m_ButtonPanelAnchor[0], m_ButtonPanelAnchor[1], m_ButtonPanelSize[0], m_ButtonPanelSize[1], m_LeftColumn, PANEL_GROUP)
101102
SetGadgetLayout(m_ButtonPanel, m_ButtonPanelAnchor[0], m_ButtonPanelSize[0], m_ButtonPanelAnchor[1], m_ButtonPanelSize[1])
103+
SetGadgetSensitivity(m_ButtonPanel, SENSITIZE_KEYS)
102104

103105
m_LoadButton = CreateButton("Load", horizMargin, 0, buttonSize[0], buttonSize[1], m_ButtonPanel, BUTTON_PUSH)
104106
m_SaveButton = CreateButton("Save", horizMargin + buttonSize[0] + vertMargin, 0, buttonSize[0], buttonSize[1], m_ButtonPanel, BUTTON_PUSH)
105107
DisableGadget(m_SaveButton)
106108

107109
m_SettingsPanel = CreatePanel(m_SettingsPanelAnchor[0], m_SettingsPanelAnchor[1], m_SettingsPanelSize[0], m_SettingsPanelSize[1], m_LeftColumn, PANEL_GROUP, " Settings : ")
108110
SetGadgetLayout(m_SettingsPanel, m_SettingsPanelAnchor[0], m_SettingsPanelSize[0], m_SettingsPanelAnchor[1], m_SettingsPanelSize[1])
111+
SetGadgetSensitivity(m_SettingsPanel, SENSITIZE_KEYS)
109112

110113
m_SettingsColorLabel = CreateLabel("BG Color", horizMargin, vertMargin, 50, labelHeight, m_SettingsPanel, LABEL_LEFT)
111114

@@ -141,6 +144,7 @@ Type UserInterface
141144

142145
m_LayeringPanel = CreatePanel(m_LayeringPanelAnchor[0], m_LayeringPanelAnchor[1], m_LayeringPanelSize[0], m_LayeringPanelSize[1], m_LeftColumn, PANEL_GROUP, " Layering Controls : ")
143146
SetGadgetLayout(m_LayeringPanel, m_LayeringPanelAnchor[0], m_LayeringPanelSize[0], m_LayeringPanelAnchor[1], m_LayeringPanelSize[1])
147+
SetGadgetSensitivity(m_LayeringPanel, SENSITIZE_KEYS)
144148

145149
m_LayeringArmFGCheckbox = CreateButton(" Arm FG — Lower Arm on top", horizMargin, vertMargin, m_LayeringPanelSize[0] - 20, 20, m_LayeringPanel, BUTTON_CHECKBOX)
146150
m_LayeringArmBGCheckbox = CreateButton(" Arm BG — Lower Arm on top", horizMargin, GadgetY(m_LayeringArmFGCheckbox) + labelVertOffset, m_LayeringPanelSize[0] - 20, 20, m_LayeringPanel, BUTTON_CHECKBOX)

0 commit comments

Comments
 (0)