Skip to content

Commit

Permalink
Bugfix: possible data loss when editing metadata in main window
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielGausi committed Apr 29, 2020
1 parent 6dcabd1 commit 98a7ba4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
29 changes: 21 additions & 8 deletions src/NempMainUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1180,8 +1180,6 @@ TNemp_MainForm = class(TNempForm)

CurrentTagToChange: String;

NewStringFromVSTEdit: String;

PaintFrameDownX: Integer;
PaintFrameDownY: Integer;

Expand Down Expand Up @@ -10518,6 +10516,8 @@ procedure TNemp_MainForm.VSTNewText(Sender: TBaseVirtualTree;
var
Data: PTreeData;
af: tAudioFile;
WriteNewStringData: Boolean;
aErr: TNempAudioError;
begin
Data := VST.GetNodeData(Node);
if assigned(Data) then
Expand All @@ -10535,8 +10535,7 @@ procedure TNemp_MainForm.VSTNewText(Sender: TBaseVirtualTree;
// Sync with ID3tags (to be sure, that no ID3Tags are deleted)
af.GetAudioData(af.Pfad); // not needed any more .... ?

NewStringFromVSTEdit := NewText;

WriteNewStringData := True;
case VST.Header.Columns[column].Tag of
CON_ARTIST : af.Artist := NewText;
CON_TITEL : af.Titel := NewText;
Expand All @@ -10550,11 +10549,25 @@ procedure TNemp_MainForm.VSTNewText(Sender: TBaseVirtualTree;
{CON_DAUER, CON_BITRATE, CON_CBR, CON_MODE, CON_SAMPLERATE, CON_FILESIZE,
CON_PFAD, CON_ORDNER, CON_DATEINAME, CON_LYRICSEXISTING, CON_EXTENSION }
// Nothing to do. Something was wrong ;-)
WriteNewStringData := False;
end;

if WriteNewStringData then
begin
aErr := af.WriteStringToMetaData(NewText, VST.Header.Columns[column].Tag, NempOptions.AllowQuickAccessToMetadata );
if (aErr = AUDIOERR_None) then
begin
SyncAudioFilesWith(af);
MedienBib.Changed := True;
CorrectVCLAfterAudioFileEdit(af);
end else
begin
// Read old Data again, if we edited something else than RATING
SynchAFileWithDisc(af, True);
TranslateMessageDLG(AudioErrorString[aErr], mtWarning, [MBOK], 0);
HandleError(afa_DirectEdit, af, aErr, True);
end;
end;
// Note: Data will be written into the File in "VSTEdited"
// TabWarning is don in VSTEdited (CorrectVCLAfterAudioFileEdit)
// if Not MedienBib.ValidKeys(af) then
// SetBrowseTabWarning(True);
end
else
TranslateMessageDLG(Warning_MedienBibBusyThread, mtWarning, [mbOK], 0);
Expand Down
6 changes: 3 additions & 3 deletions src/nemp.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
<VerInfo_AutoGenVersion>false</VerInfo_AutoGenVersion>
<VerInfo_Keys>CompanyName=;FileDescription=Noch ein Mp3-Player;FileVersion=4.13.1.682;InternalName=;LegalCopyright=2005-2019, Daniel Gaussmann;LegalTrademarks=;OriginalFilename=;ProductVersion=4.13;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys>
<VerInfo_Build>682</VerInfo_Build>
<VerInfo_Keys>CompanyName=;FileDescription=Noch ein Mp3-Player;FileVersion=4.13.2.685;InternalName=;LegalCopyright=2005-2019, Daniel Gaussmann;LegalTrademarks=;OriginalFilename=;ProductVersion=4.13;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys>
<VerInfo_Build>685</VerInfo_Build>
<VerInfo_MinorVer>13</VerInfo_MinorVer>
<DCC_Define>madExcept;$(DCC_Define)</DCC_Define>
<DCC_MapFile>3</DCC_MapFile>
<DCC_DebugInformation>2</DCC_DebugInformation>
<VerInfo_AutoIncVersion>true</VerInfo_AutoIncVersion>
<DCC_LocalDebugSymbols>true</DCC_LocalDebugSymbols>
<BT_BuildType>Debug</BT_BuildType>
<VerInfo_Release>1</VerInfo_Release>
<VerInfo_Release>2</VerInfo_Release>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<Manifest_File>None</Manifest_File>
Expand Down

0 comments on commit 98a7ba4

Please sign in to comment.