mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 13:37:42 -05:00
fix: Saving layout now picks the first path in the list (#2208)
<!-- Please provide as much information as possible about what your PR aims to do. PRs with no description will most likely be closed until more information is provided. If you're planing on changing fundamental behaviour or add big new features, please open a GitHub Issue first before starting to work on it. If it's not something big and you still want to contact us about it, feel free to do so ! --> ### Problem description Saving a layout using the "Workspace -> Layout -> Save Layout ..." button saved to the last writable path in the list that can be found in the "Help -> About" menu. Instead, it should write to the first working path encountered. ### Implementation description Getting all of the writable paths, then picking the first one. ### Screenshots <!-- If your change is visual, take a screenshot showing it. Ideally, make before/after sceenshots --> ### Additional things <!-- Anything else you would like to say -->
This commit is contained in:
@@ -43,19 +43,25 @@ namespace hex {
|
||||
|
||||
std::fs::path layoutPath;
|
||||
for (const auto &path : paths::Layouts.write()) {
|
||||
layoutPath = path / fileName;
|
||||
}
|
||||
size_t outSize = 0;
|
||||
const char* iniData = ImGui::SaveIniSettingsToMemory(&outSize);
|
||||
|
||||
if (layoutPath.empty()) {
|
||||
log::error("Failed to save layout '{}'. No writable path found", name);
|
||||
layoutPath = path / fileName;
|
||||
wolv::io::File file = wolv::io::File(layoutPath, wolv::io::File::Mode::Write);
|
||||
if (!file.isValid()) {
|
||||
log::warn("Failed to save layout '{}'. Could not open file '{}', continuing with next path", name, layoutPath.c_str());
|
||||
continue;
|
||||
}
|
||||
size_t written = file.writeBuffer((const u8*) iniData, outSize);
|
||||
if (written != outSize) {
|
||||
log::warn("Failed to save layout '{}'. Could not write file '{}', continuing with next path", name, layoutPath.c_str());
|
||||
continue;
|
||||
}
|
||||
log::info("Layout '{}' saved to '{}'", name, layoutPath.c_str());
|
||||
LayoutManager::reload();
|
||||
return;
|
||||
}
|
||||
|
||||
const auto pathString = wolv::util::toUTF8String(layoutPath);
|
||||
ImGui::SaveIniSettingsToDisk(pathString.c_str());
|
||||
log::info("Layout '{}' saved to {}", name, pathString);
|
||||
|
||||
LayoutManager::reload();
|
||||
log::error("Failed to save layout '{}'. No writable path found", name);
|
||||
}
|
||||
|
||||
std::string LayoutManager::saveToString() {
|
||||
|
||||
Reference in New Issue
Block a user