Fixed multiple segfaults

This commit is contained in:
Yousef Khadadeh 2026-03-30 18:51:14 +03:00
parent b4c35124c3
commit 2ad5684594
32 changed files with 1035 additions and 1010 deletions

View file

@ -51,29 +51,29 @@ void ImageEditTool::edit_gui(CanvasComponentContainer::ObjInfo* comp) {
ImageCanvasComponent& a = static_cast<ImageCanvasComponent&>(comp->obj->get_comp());
Toolbar& t = drawP.world.main.toolbar;
t.gui.push_id("edit tool image");
text_label_centered(t.gui, "File Properties");
auto resourceData = drawP.world.netObjMan.get_obj_temporary_ref_from_id<ResourceData>(a.d.imageID);
t.gui.new_id("edit tool image", [&] {
text_label_centered(t.gui, "File Properties");
auto resourceData = drawP.world.netObjMan.get_obj_temporary_ref_from_id<ResourceData>(a.d.imageID);
if(resourceData) {
text_label(t.gui, "Name: " + resourceData->name);
text_button(t.gui, "file download", "Download file", {
.wide = true,
.onClick = [&] {
#ifdef __EMSCRIPTEN__
emscripten_browser_file::download(
resourceData->name,
"application/octet-binary",
*resourceData->data
);
#endif
t.open_file_selector("Download File", {{"Any File", "*"}}, [resourceData](const std::filesystem::path& p, const auto& e) {
SDL_SaveFile(p.c_str(), resourceData->data->c_str(), resourceData->data->size());
}, resourceData->name, true);
}
});
}
else
text_label_centered(t.gui, "Loading resource...");
t.gui.pop_id();
if(resourceData) {
text_label(t.gui, "Name: " + resourceData->name);
text_button(t.gui, "file download", "Download file", {
.wide = true,
.onClick = [&] {
#ifdef __EMSCRIPTEN__
emscripten_browser_file::download(
resourceData->name,
"application/octet-binary",
*resourceData->data
);
#endif
t.open_file_selector("Download File", {{"Any File", "*"}}, [resourceData](const std::filesystem::path& p, const auto& e) {
SDL_SaveFile(p.c_str(), resourceData->data->c_str(), resourceData->data->size());
}, resourceData->name, true);
}
});
}
else
text_label_centered(t.gui, "Loading resource...");
});
}