From f570e2f2685aa43aa518c2f8578391c1847cddbe Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:04:59 +0200 Subject: 3.3 --- RealtimeSync/resources.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'RealtimeSync/resources.cpp') diff --git a/RealtimeSync/resources.cpp b/RealtimeSync/resources.cpp index fe2a5ced..eeb89563 100644 --- a/RealtimeSync/resources.cpp +++ b/RealtimeSync/resources.cpp @@ -19,12 +19,7 @@ const GlobalResources& GlobalResources::getInstance() GlobalResources::GlobalResources() { - //map, allocate and initialize pictures - bitmapResource[wxT("start red.png")] = (bitmapStart = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("add pair.png")] = (bitmapAddFolderPair = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("remove pair.png")] = (bitmapRemoveFolderPair = new wxBitmap(wxNullBitmap)); - - programIcon = new wxIcon(wxNullIcon); + programIcon = new wxIcon(wxNullIcon); } @@ -49,7 +44,6 @@ void GlobalResources::load() const wxZipInputStream resourceFile(input); - std::map::iterator bmp; while (true) { std::auto_ptr entry(resourceFile.GetNextEntry()); @@ -58,24 +52,31 @@ void GlobalResources::load() const const wxString name = entry->GetName(); - //search if entry is available in map - if ((bmp = bitmapResource.find(name)) != bitmapResource.end()) - *(bmp->second) = wxBitmap(wxImage(resourceFile, wxBITMAP_TYPE_PNG)); + //generic image loading + if (name.EndsWith(wxT(".png"))) + { + if (bitmapResource.find(name) == bitmapResource.end()) //avoid duplicate entry: prevent memory leak! + bitmapResource[name] = new wxBitmap(wxImage(resourceFile, wxBITMAP_TYPE_PNG)); + } } } #ifdef FFS_WIN + //for compatibility it seems we need to stick with a "real" icon *programIcon = wxIcon(wxT("A_PROGRAM_ICON")); #else -#include "RealtimeSync.xpm" - *programIcon = wxIcon(RealtimeSync_xpm); + //use big logo bitmap for better quality + programIcon->CopyFromBitmap(getImageByName(wxT("RealtimeSync.png"))); #endif } const wxBitmap& GlobalResources::getImageByName(const wxString& imageName) const { - std::map::const_iterator bmp = bitmapResource.find(imageName); + const std::map::const_iterator bmp = imageName.Find(wxChar('.')) == wxNOT_FOUND ? //assume .png ending if nothing else specified + bitmapResource.find(imageName + wxT(".png")) : + bitmapResource.find(imageName); + if (bmp != bitmapResource.end()) return *bmp->second; else -- cgit