View Issue Details

IDProjectCategoryView StatusLast Update
0001161OpenMPT[All Projects] File Format Supportpublic2018-11-11 15:37
ReporterSaga MusixAssigned ToSaga Musix 
PrioritynormalSeverityminorReproducibilityN/A
Status assignedResolutionopen 
Product Version 
Target VersionOpenMPT 1.?? (long term goals)Fixed in Version 
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.
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 assignedmanx Properly report and handle out-of-memory 

Activities

Saga Musix

Saga Musix

2018-11-11 14:56

administrator  

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();
 	}
Saga Musix

Saga Musix

2018-11-11 15:20

administrator   ~0003711

Last edited: 2018-11-11 15:28

View 3 revisions

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.

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 View Revisions
2018-11-11 15:28 Saga Musix Note Edited: 0003711 View Revisions
2018-11-11 15:37 Saga Musix Assigned To => Saga Musix
2018-11-11 15:37 Saga Musix Status new => assigned