MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / load

Method load

pcsx2-qt/Debugger/Docking/DockLayout.cpp:657–829  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

655}
656
657void DockLayout::load(
658 const std::string& path,
659 LoadResult& result,
660 DockLayout::Index& index_last_session)
661{
662 pxAssert(!m_is_active);
663
664 result = SUCCESS;
665
666 std::optional<std::string> text = FileSystem::ReadFileToString(path.c_str());
667 if (!text.has_value())
668 {
669 Console.Error("Debugger: Failed to open layout file '%s'.", path.c_str());
670 result = FILE_NOT_FOUND;
671 return;
672 }
673
674 rapidjson::Document json;
675 if (json.Parse(text->c_str()).HasParseError() || !json.IsObject())
676 {
677 Console.Error("Debugger: Failed to parse layout file '%s' as JSON.", path.c_str());
678 result = INVALID_FORMAT;
679 return;
680 }
681
682 auto format = json.FindMember("format");
683 if (format == json.MemberEnd() ||
684 !format->value.IsString() ||
685 strcmp(format->value.GetString(), DEBUGGER_LAYOUT_FILE_FORMAT) != 0)
686 {
687 Console.Error("Debugger: Layout file '%s' has missing or invalid 'format' property.", path.c_str());
688 result = INVALID_FORMAT;
689 return;
690 }
691
692 auto version_major = json.FindMember("versionMajor");
693 if (version_major == json.MemberEnd() || !version_major->value.IsInt())
694 {
695 Console.Error("Debugger: Layout file '%s' has missing or invalid 'versionMajor' property.", path.c_str());
696 result = MAJOR_VERSION_MISMATCH;
697 return;
698 }
699
700 if (version_major->value.GetInt() != DEBUGGER_LAYOUT_FILE_VERSION_MAJOR)
701 {
702 result = MAJOR_VERSION_MISMATCH;
703 return;
704 }
705
706 auto version_minor = json.FindMember("versionMinor");
707 if (version_minor == json.MemberEnd() || !version_minor->value.IsInt())
708 {
709 Console.Error("Debugger: Layout file '%s' has missing or invalid 'versionMinor' property.", path.c_str());
710 result = MAJOR_VERSION_MISMATCH;
711 return;
712 }
713
714 auto default_layout_hash = json.FindMember("defaultLayoutHash");

Callers 9

mainFunction · 0.45
PumpPlatformMessagesMethod · 0.45
InstallTranslatorMethod · 0.45
isRunningFullscreenUIMethod · 0.45
stopFullscreenUIMethod · 0.45
runMethod · 0.45
IsCancelledMethod · 0.45
loadOrGenerateCoverMethod · 0.45
loadCommonImagesMethod · 0.45

Calls 15

FindMemberMethod · 0.80
MemberEndMethod · 0.80
GetStringMethod · 0.80
GetIntMethod · 0.80
GetBoolMethod · 0.80
MemberBeginMethod · 0.80
IsUint64Method · 0.80
getFunction · 0.50
c_strMethod · 0.45
ErrorMethod · 0.45
HasParseErrorMethod · 0.45
ParseMethod · 0.45

Tested by

no test coverage detected