summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2022-06-10 01:28:27 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2022-06-10 01:28:27 -0400
commit5cf4d8e160dd5bb2a8681106c030ecee152c7366 (patch)
treecbdb5e2da2b19c69cd631309af405425d3749512 /src
parent49ff9a249e4fbc6354810fb56a7488deeacd8cd2 (diff)
downloadabaddon-portaudio-5cf4d8e160dd5bb2a8681106c030ecee152c7366.tar.gz
abaddon-portaudio-5cf4d8e160dd5bb2a8681106c030ecee152c7366.zip
dont use tmpnam because its stupid
Diffstat (limited to 'src')
-rw-r--r--src/components/chatinput.cpp12
1 files changed, 3 insertions, 9 deletions
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<Gdk::Pixbuf> &pb) {
if (m_attachments.size() == 10) return false;
- std::array<char, L_tmpnam> 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");