View Issue Details

IDProjectCategoryView StatusLast Update
0001161OpenMPTFile Format Supportpublic2021-03-31 19:49
ReporterSaga Musix Assigned ToSaga Musix  
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Target VersionOpenMPT 1.30.01.00 / libopenmpt 0.6.0 (upgrade first)Fixed in VersionOpenMPT 1.30.01.00 / libopenmpt 0.6.0 (upgrade first) 
Summary0001161: Notify user about file write failures
Description

OpenMPT does not notify the user if some data could not be written to a file (e.g. because the disk is full). At least for regular saving (not autosave), the user should get notified if there is a write failure.

Additional Information

Least intrusive way to implement might be to enable exceptions for badbit/failbit in the code that calls the export functions.

TagsNo tags attached.
Attached Files
enable-exceptions-in-module-saving.patch (1,241 bytes)   
Index: mptrack/Moddoc.cpp
===================================================================
--- mptrack/Moddoc.cpp	(revision 10968)
+++ mptrack/Moddoc.cpp	(working copy)
@@ -284,14 +284,21 @@
 		BeginWaitCursor();
 		FixNullStrings();
 		m_SndFile.m_dwLastSavedWithVersion = Version::Current();
-		switch(m_SndFile.GetType())
+		try
 		{
-		case MOD_TYPE_MOD: ok = m_SndFile.SaveMod(f); break;
-		case MOD_TYPE_S3M: ok = m_SndFile.SaveS3M(f); break;
-		case MOD_TYPE_XM:  ok = m_SndFile.SaveXM(f); break;
-		case MOD_TYPE_IT:  ok = m_SndFile.SaveIT(f, filename); break;
-		case MOD_TYPE_MPT: ok = m_SndFile.SaveIT(f, filename); break;
-		default:           MPT_ASSERT_NOTREACHED();
+			f.exceptions(f.exceptions() | std::ios::badbit | std::ios::failbit);
+			switch(m_SndFile.GetType())
+			{
+			case MOD_TYPE_MOD: ok = m_SndFile.SaveMod(f); break;
+			case MOD_TYPE_S3M: ok = m_SndFile.SaveS3M(f); break;
+			case MOD_TYPE_XM:  ok = m_SndFile.SaveXM(f); break;
+			case MOD_TYPE_IT:  ok = m_SndFile.SaveIT(f, filename); break;
+			case MOD_TYPE_MPT: ok = m_SndFile.SaveIT(f, filename); break;
+			default:           MPT_ASSERT_NOTREACHED();
+			}
+		} catch(const std::exception &)
+		{
+			ok = FALSE;
 		}
 		EndWaitCursor();
 	}
Has the bug occurred in previous versions?
Tested code revision (in case you know it)

Relationships

related to 0001157 resolvedmanx Corrupted filesave 
related to 0001112 acknowledgedmanx Properly report and handle out-of-memory 

Activities

Saga Musix

Saga Musix

2018-11-11 15:20

administrator   ~0003711

Last edited: 2018-11-11 15:28

This patch has now been applied. We should do something similar for saving samples and instruments. With samples, we might have to change some sample savers making use of external libraries though, to make sure that the library resources are handled in RAII style (Update: FLAC is already RAII, and all other formats are built-in). We should also move the file stream creation out of the sample savers, like we did with module savers.

Saga Musix

Saga Musix

2018-12-22 12:32

administrator   ~0003763

Failure on MIDI export now also warns the user. For stream export and sample / instrument saving, exceptions are currently not enabled, as the WAV writer may throw in its destructor. This will be fixed later.

Saga Musix

Saga Musix

2020-07-18 14:06

administrator   ~0004399

r13310 notifies of write failures when saving samples/instruments. Stream export is missing, since some stream exporters still throw in their destructor.

Saga Musix

Saga Musix

2020-07-18 16:34

administrator   ~0004400

r13312 fixes a crash that was already present in 1.29 and went undetected while testing this feature: Exception while flushing the output file were never caught. This revision also adds exceptions to compatibility export, saving tuning files, envelopes and plugin presets.

Saga Musix

Saga Musix

2020-07-18 16:39

administrator   ~0004401

As of r13314, stream export can now also report write failures. This concludes the work regarding this issue.

Saga Musix

Saga Musix

2021-03-31 19:49

administrator   ~0004697

r14543 also enables exception in two places where it was previously forgotten.

Issue History

Date Modified Username Field Change
2018-11-06 19:14 Saga Musix New Issue
2018-11-06 19:16 manx Relationship added related to 0001157
2018-11-06 19:16 manx Relationship added related to 0001112
2018-11-11 14:56 Saga Musix File Added: enable-exceptions-in-module-saving.patch
2018-11-11 15:20 Saga Musix Note Added: 0003711
2018-11-11 15:24 Saga Musix Note Edited: 0003711
2018-11-11 15:28 Saga Musix Note Edited: 0003711
2018-11-11 15:37 Saga Musix Assigned To => Saga Musix
2018-11-11 15:37 Saga Musix Status new => assigned
2018-12-22 12:32 Saga Musix Note Added: 0003763
2018-12-23 13:24 Saga Musix Target Version OpenMPT 1.?? (long term goals) => libopenmpt 0.5 (goals)
2018-12-23 13:24 Saga Musix Target Version libopenmpt 0.5 (goals) => OpenMPT 1.29.01.00 / libopenmpt 0.5.0 (upgrade first)
2020-01-05 10:43 manx Target Version OpenMPT 1.29.01.00 / libopenmpt 0.5.0 (upgrade first) => OpenMPT 1.30.01.00 / libopenmpt 0.6.0 (upgrade first)
2020-07-18 14:06 Saga Musix Note Added: 0004399
2020-07-18 16:34 Saga Musix Note Added: 0004400
2020-07-18 16:39 Saga Musix Note Added: 0004401
2020-07-18 16:39 Saga Musix Status assigned => resolved
2020-07-18 16:39 Saga Musix Resolution open => fixed
2020-07-18 16:39 Saga Musix Fixed in Version => OpenMPT 1.30.01.00 / libopenmpt 0.6.0 (upgrade first)
2021-03-31 19:49 Saga Musix Note Added: 0004697