Skip to content

Commit

Permalink
Merged revision(s) 22608 from trunk/OpenMPT:
Browse files Browse the repository at this point in the history
[Fix] mpt/base/detect_quirks.hpp: Add MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE for older Apple Clang. See <fink/fink-distributions#1202>.
........


git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.30@22615 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
manxorist committed Dec 26, 2024
1 parent c938b7e commit ba0b1bf
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions common/mptFileIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,11 @@ OnDiskFileWrapper::OnDiskFileWrapper(FileCursor &file, const mpt::PathString &fi
m_IsTempFile = true;
} else
{
#if defined(MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE)
m_Filename = *(file.GetOptionalFileName());
#else
m_Filename = file.GetOptionalFileName().value();
#endif
}
} catch (const std::runtime_error &)
{
Expand Down
6 changes: 6 additions & 0 deletions soundlib/Dlsbank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,13 @@ bool CDLSBank::Open(FileReader file)
uint32 nInsDef;

if(file.GetOptionalFileName())
{
#if defined(MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE)
m_szFileName = *(file.GetOptionalFileName());
#else
m_szFileName = file.GetOptionalFileName().value();
#endif
}

file.Rewind();
size_t dwMemLength = file.GetLength();
Expand Down
4 changes: 4 additions & 0 deletions soundlib/Load_mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,11 @@ bool CSoundFile::ReadMOD(FileReader &file, ModLoadingFlags loadFlags)
FileReader amData;
if(file.GetOptionalFileName())
{
#if defined(MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE)
mpt::PathString filename = *(file.GetOptionalFileName());
#else
mpt::PathString filename = file.GetOptionalFileName().value();
#endif
// Find instrument definition file
const mpt::PathString exts[] = {P_(".nt"), P_(".NT"), P_(".as"), P_(".AS")};
for(const auto &ext : exts)
Expand Down
16 changes: 16 additions & 0 deletions src/mpt/base/detect_quirks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,20 @@



#if MPT_OS_MACOSX_OR_IOS
#if defined(TARGET_OS_OSX)
#if TARGET_OS_OSX
#if !defined(MAC_OS_X_VERSION_10_14)
#define MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE
#else
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14)
#define MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE
#endif
#endif
#endif
#endif
#endif



#endif // MPT_BASE_DETECT_QUIRKS_HPP
12 changes: 12 additions & 0 deletions src/mpt/library/library.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ class library {
if (!optionalfilename) {
return std::nullopt;
}
#if defined(MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE)
mpt::path & filename = *optionalfilename;
#else
mpt::path & filename = optionalfilename.value();
#endif
if (filename.empty()) {
return std::nullopt;
}
Expand Down Expand Up @@ -330,7 +334,11 @@ class library {
if (!optionalfilename) {
return std::nullopt;
}
#if defined(MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE)
mpt::path & filename = *optionalfilename;
#else
mpt::path & filename = optionalfilename.value();
#endif
if (filename.empty()) {
return std::nullopt;
}
Expand Down Expand Up @@ -384,7 +392,11 @@ class library {
if (!optionalfilename) {
return std::nullopt;
}
#if defined(MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE)
mpt::path & filename = *optionalfilename;
#else
mpt::path & filename = optionalfilename.value();
#endif
if (filename.empty()) {
return std::nullopt;
}
Expand Down

0 comments on commit ba0b1bf

Please sign in to comment.