From 5cf4d8e160dd5bb2a8681106c030ecee152c7366 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 10 Jun 2022 01:28:27 -0400 Subject: dont use tmpnam because its stupid --- src/components/chatinput.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/components/chatinput.cpp b/src/components/chatinput.cpp index 166d04f..f9bbce4 100644 --- a/src/components/chatinput.cpp +++ b/src/components/chatinput.cpp @@ -122,15 +122,9 @@ void ChatInputAttachmentContainer::ClearNoPurge() { bool ChatInputAttachmentContainer::AddImage(const Glib::RefPtr &pb) { if (m_attachments.size() == 10) return false; - std::array dest_name {}; - if (std::tmpnam(dest_name.data()) == nullptr) { - fprintf(stderr, "failed to get temporary path\n"); - return false; - } - - std::filesystem::path part1(std::filesystem::temp_directory_path() / "abaddon-cache"); - std::filesystem::path part2(dest_name.data()); - const auto path = (part1 / part2.relative_path()).string(); + static unsigned go_up = 0; + std::string dest_name = "pasted-image-" + std::to_string(go_up++); + const auto path = (std::filesystem::temp_directory_path() / "abaddon-cache" / dest_name).string(); try { pb->save(path, "png"); -- cgit v1.2.3