From 4c392178dac1de9a299beb78989c4e0f3fecade9 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 20 May 2018 11:15:15 +0200 Subject: Add image preview and url/image open in browser --- src/Cache.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/Cache.cpp') diff --git a/src/Cache.cpp b/src/Cache.cpp index 074b7bc..e5d910c 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -5,6 +5,8 @@ #include "../include/Gif.hpp" #include "../include/Chatbar.hpp" #include "../include/WebPagePreview.hpp" +#include "../include/ImagePreview.hpp" +#include "../include/StringUtils.hpp" #include #include #include @@ -267,11 +269,21 @@ namespace dchat { case ContentByUrlResult::CachedType::TEXTURE: { + if(ImagePreview::getPreviewContentPtr() == it->second.texture) + { + ++it; + continue; + } delete it->second.texture; break; } case ContentByUrlResult::CachedType::GIF: { + if(ImagePreview::getPreviewContentPtr() == it->second.texture) + { + ++it; + continue; + } delete it->second.gif; break; } @@ -311,18 +323,6 @@ namespace dchat } } - static string stringReplaceChar(const string &str, const string &from, const string &to) - { - string result = str; - size_t pos = 0; - while((pos = result.find(from, pos)) != string::npos) - { - result.replace(pos, from.size(), to); - pos += to.size(); - } - return result; - } - const ContentByUrlResult Cache::getContentByUrl(const string &url, int downloadLimitBytes) { lock_guard lock(imageDownloadMutex); -- cgit v1.2.3