Skip to content

Commit

Permalink
chore: use raii release comptr
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Oct 12, 2024
1 parent 204312a commit da55b0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ll/api/command/EnumName.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ struct enum_name<SoftEnum<T>> {
static constexpr char const* value = unprefix_name_for_c<T>::stored_name.c_str();
};
template <class T>
static constexpr char const* enum_name_v = enum_name<T>::value;
constexpr char const* enum_name_v = enum_name<T>::value;
} // namespace ll::command
9 changes: 3 additions & 6 deletions src/ll/api/utils/FontUtils_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static std::vector<std::filesystem::path> getFilePathFromIDWriteFontFace(IDWrite
if (!SUCCEEDED(hr)) {
return result;
}
std::unique_ptr<IDWriteFontFile*[]> fontFiles = std::make_unique_for_overwrite<IDWriteFontFile*[]>(fileCount);
hr = fontFace.GetFiles(&fileCount, fontFiles.get());
std::unique_ptr<CComPtr<IDWriteFontFile>[]> fontFiles = std::make_unique<CComPtr<IDWriteFontFile>[]>(fileCount);
hr = fontFace.GetFiles(&fileCount, reinterpret_cast<IDWriteFontFile**>(fontFiles.get()));
for (uint i = 0; i < fileCount; i++) {
IDWriteFontFile* fontFile = fontFiles[i];

Expand Down Expand Up @@ -65,9 +65,6 @@ static std::vector<std::filesystem::path> getFilePathFromIDWriteFontFace(IDWrite
}
result.push_back(std::move(filePath));
}
for (uint i = 0; i < fileCount; i++) {
fontFiles[i]->Release();
}
return result;
}

Expand Down Expand Up @@ -155,9 +152,9 @@ std::vector<std::string> getSystemFontNames() {
if (SUCCEEDED(hr)) {
familyCount = pFontCollection->GetFontFamilyCount();
}
std::wstring localeCode = str2wstr(i18n::getDefaultLocaleCode());
std::vector<std::string> result;
result.reserve(familyCount);
std::wstring localeCode = str2wstr(i18n::getDefaultLocaleCode());
for (UINT32 i = 0; i < familyCount; ++i) {
CComPtr<IDWriteFontFamily> pFontFamily;
// Get the font family.
Expand Down

0 comments on commit da55b0e

Please sign in to comment.