Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions src/Host/8bf/host_8bf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,8 @@ namespace

InputFileParseStatus ReadColorProfile(const QString& path, cmsContext context, cmsHPROFILE* outProfile)
{
*outProfile = nullptr;

QFile file(path);

if (!file.open(QIODevice::ReadOnly))
Expand Down Expand Up @@ -1129,23 +1131,27 @@ namespace

host_8bf::lcmsContext = cmsCreateContext(nullptr, nullptr);

if (host_8bf::lcmsContext == nullptr)
{
return InputFileParseStatus::IccProfileError;
}

InputFileParseStatus status = ReadColorProfile(imageColorProfile, host_8bf::lcmsContext, &host_8bf::imageProfile);

if (status != InputFileParseStatus::Ok)
if (host_8bf::lcmsContext != nullptr)
{
return status;
}
InputFileParseStatus status = ReadColorProfile(imageColorProfile, host_8bf::lcmsContext, &host_8bf::imageProfile);

status = ReadColorProfile(displayColorProfile, host_8bf::lcmsContext, &host_8bf::displayProfile);

if (status != InputFileParseStatus::Ok)
{
return status;
if (status == InputFileParseStatus::Ok)
{
status = ReadColorProfile(displayColorProfile, host_8bf::lcmsContext, &host_8bf::displayProfile);

if (status != InputFileParseStatus::Ok)
{
cmsCloseProfile(host_8bf::imageProfile);
host_8bf::imageProfile = nullptr;
cmsDeleteContext(host_8bf::lcmsContext);
host_8bf::lcmsContext = nullptr;
}
}
else
{
cmsDeleteContext(host_8bf::lcmsContext);
host_8bf::lcmsContext = nullptr;
}
}
}

Expand Down