mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 08:59:28 +02:00
Char width info goes in the unique data dictionary only once per run (#613)
This commit is contained in:
parent
6eb6aab8f5
commit
87d82e76c7
@ -16,6 +16,7 @@
|
|||||||
#include "Audacity.h"
|
#include "Audacity.h"
|
||||||
#include "ProjectSerializer.h"
|
#include "ProjectSerializer.h"
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
#include <wx/ustring.h>
|
#include <wx/ustring.h>
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -89,11 +90,16 @@ ProjectSerializer::ProjectSerializer(size_t allocSize)
|
|||||||
mDict.SetBufSize(allocSize);
|
mDict.SetBufSize(allocSize);
|
||||||
mBuffer.SetBufSize(allocSize);
|
mBuffer.SetBufSize(allocSize);
|
||||||
|
|
||||||
|
std::once_flag flag;
|
||||||
|
std::call_once(flag, []{
|
||||||
|
// Just once per run, store header information in the unique static
|
||||||
|
// dictionary that will be written into each project that is saved.
|
||||||
// Store the size of "wxChar" so we can convert during recovery in
|
// Store the size of "wxChar" so we can convert during recovery in
|
||||||
// case the file is used on a system with a different character size.
|
// case the file is used on a system with a different character size.
|
||||||
char size = sizeof(wxChar);
|
char size = sizeof(wxChar);
|
||||||
mDict.AppendByte(FT_CharSize);
|
mDict.AppendByte(FT_CharSize);
|
||||||
mDict.AppendData(&size, sizeof(size));
|
mDict.AppendData(&size, sizeof(size));
|
||||||
|
});
|
||||||
|
|
||||||
mDictChanged = false;
|
mDictChanged = false;
|
||||||
}
|
}
|
||||||
@ -230,6 +236,8 @@ void ProjectSerializer::WriteName(const wxString & name)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// mNames is static. This appends each name to static mDict only once
|
||||||
|
// in each run.
|
||||||
short len = name.length() * sizeof(wxChar);
|
short len = name.length() * sizeof(wxChar);
|
||||||
|
|
||||||
id = mNames.size();
|
id = mNames.size();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user