From 0730b1b494e650e76a7fcd1a70d5f305e7aed7a3 Mon Sep 17 00:00:00 2001 From: Beep6581 Date: Fri, 27 Nov 2015 20:16:04 +0100 Subject: [PATCH 01/11] Added MAIN_BUTTON_SENDTOEDITOR language string --- rtdata/languages/Catala | 1 + rtdata/languages/Czech | 1 + rtdata/languages/English (UK) | 1 + rtdata/languages/English (US) | 1 + rtdata/languages/Francais | 1 + rtdata/languages/Italiano | 1 + rtdata/languages/Japanese | 1 + rtdata/languages/Nederlands | 1 + rtdata/languages/Polish | 1 + rtdata/languages/Polish (Latin Characters) | 1 + rtdata/languages/Russian | 1 + rtdata/languages/Swedish | 1 + rtdata/languages/default | 1 + 13 files changed, 13 insertions(+) diff --git a/rtdata/languages/Catala b/rtdata/languages/Catala index 414b7a4bb..269e122d4 100644 --- a/rtdata/languages/Catala +++ b/rtdata/languages/Catala @@ -1294,6 +1294,7 @@ ZOOMPANEL_ZOOMOUT;Allunya\nDrecera: - !MAIN_BUTTON_NAVNEXT_TOOLTIP;Navigate to the next image relative to image opened in the Editor.\nShortcut: Shift-F4\n\nTo navigate to the next image relative to the currently selected thumbnail in the File Browser or Filmstrip:\nShortcut: F4 !MAIN_BUTTON_NAVPREV_TOOLTIP;Navigate to the previous image relative to image opened in the Editor.\nShortcut: Shift-F3\n\nTo navigate to the previous image relative to the currently selected thumbnail in the File Browser or Filmstrip:\nShortcut: F3 !MAIN_BUTTON_NAVSYNC_TOOLTIP;Synchronize the File Browser or Filmstrip with the Editor to reveal the thumbnail of the currently opened image, and clear any active filters.\nShortcut: x\n\nAs above, but without clearing active filters:\nShortcut: y\n(Note that the thumbnail of the opened image will not be shown if filtered out). +!MAIN_BUTTON_SENDTOEDITOR;Edit image in external editor !MAIN_MSG_OPERATIONCANCELLED;Operation cancelled !MAIN_MSG_PATHDOESNTEXIST;The path\n\n%1\n\ndoes not exist. Please set a correct path in Preferences. !MAIN_MSG_SETPATHFIRST;You first have to set a target path in Preferences in order to use this function! diff --git a/rtdata/languages/Czech b/rtdata/languages/Czech index 423a0e41d..b6d64cc45 100644 --- a/rtdata/languages/Czech +++ b/rtdata/languages/Czech @@ -1999,4 +1999,5 @@ ZOOMPANEL_ZOOMOUT;Oddálit\nZkratka: - !!!!!!!!!!!!!!!!!!!!!!!!! !HISTORY_MSG_166;Exposure - Reset +!MAIN_BUTTON_SENDTOEDITOR;Edit image in external editor !TP_NEUTRAL;Reset diff --git a/rtdata/languages/English (UK) b/rtdata/languages/English (UK) index 3f54ab72b..f0cdc3390 100644 --- a/rtdata/languages/English (UK) +++ b/rtdata/languages/English (UK) @@ -788,6 +788,7 @@ TP_WBALANCE_EQBLUERED_TOOLTIP;Allows to deviate from the normal behaviour of "wh !MAIN_BUTTON_PREFERENCES;Preferences !MAIN_BUTTON_PUTTOQUEUE_TOOLTIP;Put current image to processing queue.\nShortcut: Ctrl+b !MAIN_BUTTON_SAVE_TOOLTIP;Save current image.\nShortcut: Ctrl+s +!MAIN_BUTTON_SENDTOEDITOR;Edit image in external editor !MAIN_BUTTON_SENDTOEDITOR_TOOLTIP;Edit current image in external editor.\nShortcut: Ctrl+e !MAIN_BUTTON_SHOWHIDESIDEPANELS_TOOLTIP;Show/hide all side panels.\nShortcut: m !MAIN_BUTTON_UNFULLSCREEN;Exit fullscreen diff --git a/rtdata/languages/English (US) b/rtdata/languages/English (US) index 56f004c7f..82087395d 100644 --- a/rtdata/languages/English (US) +++ b/rtdata/languages/English (US) @@ -709,6 +709,7 @@ !MAIN_BUTTON_PREFERENCES;Preferences !MAIN_BUTTON_PUTTOQUEUE_TOOLTIP;Put current image to processing queue.\nShortcut: Ctrl+b !MAIN_BUTTON_SAVE_TOOLTIP;Save current image.\nShortcut: Ctrl+s +!MAIN_BUTTON_SENDTOEDITOR;Edit image in external editor !MAIN_BUTTON_SENDTOEDITOR_TOOLTIP;Edit current image in external editor.\nShortcut: Ctrl+e !MAIN_BUTTON_SHOWHIDESIDEPANELS_TOOLTIP;Show/hide all side panels.\nShortcut: m !MAIN_BUTTON_UNFULLSCREEN;Exit fullscreen diff --git a/rtdata/languages/Francais b/rtdata/languages/Francais index 18ba97142..9c57dd7d4 100644 --- a/rtdata/languages/Francais +++ b/rtdata/languages/Francais @@ -1912,6 +1912,7 @@ ZOOMPANEL_ZOOMOUT;Zoom Arrière\nRaccourci: - !HISTORY_MSG_424;Retinex - HL threshold !HISTORY_MSG_425;Retinex - Log base !HISTORY_MSG_426;Retinex - Hue equalizer +!MAIN_BUTTON_SENDTOEDITOR;Edit image in external editor !PARTIALPASTE_RETINEX;Retinex !PREFERENCES_TUNNELMETADATA;Copy Exif/IPTC/XMP unchanged to output file !SAVEDLG_SUBSAMP_TOOLTIP;Best compression:\nJ:a:b 4:2:0\nh/v 2/2\nChroma halved horizontally and vertically.\n\nBalanced:\nJ:a:b 4:2:2\nh/v 2/1\nChroma halved horizontally.\n\nBest quality:\nJ:a:b 4:4:4\nh/v 1/1\nNo chroma subsampling. diff --git a/rtdata/languages/Italiano b/rtdata/languages/Italiano index fd3991a53..1268b74d2 100644 --- a/rtdata/languages/Italiano +++ b/rtdata/languages/Italiano @@ -1558,6 +1558,7 @@ ZOOMPANEL_ZOOMOUT;Rimpicciolisci.\nScorciatoia: - !HISTORY_MSG_424;Retinex - HL threshold !HISTORY_MSG_425;Retinex - Log base !HISTORY_MSG_426;Retinex - Hue equalizer +!MAIN_BUTTON_SENDTOEDITOR;Edit image in external editor !MAIN_TAB_INSPECT; Inspect !MAIN_TAB_WAVELET;Wavelet !MAIN_TAB_WAVELET_TOOLTIP;Shortcut: Alt-w diff --git a/rtdata/languages/Japanese b/rtdata/languages/Japanese index e3a29fe2a..164d9d5de 100644 --- a/rtdata/languages/Japanese +++ b/rtdata/languages/Japanese @@ -1946,6 +1946,7 @@ ZOOMPANEL_ZOOMOUT;ズームアウト\nショートカット: - !HISTORY_MSG_424;Retinex - HL threshold !HISTORY_MSG_425;Retinex - Log base !HISTORY_MSG_426;Retinex - Hue equalizer +!MAIN_BUTTON_SENDTOEDITOR;Edit image in external editor !PARTIALPASTE_RETINEX;Retinex !PREFERENCES_TUNNELMETADATA;Copy Exif/IPTC/XMP unchanged to output file !SAVEDLG_SUBSAMP_TOOLTIP;Best compression:\nJ:a:b 4:2:0\nh/v 2/2\nChroma halved horizontally and vertically.\n\nBalanced:\nJ:a:b 4:2:2\nh/v 2/1\nChroma halved horizontally.\n\nBest quality:\nJ:a:b 4:4:4\nh/v 1/1\nNo chroma subsampling. diff --git a/rtdata/languages/Nederlands b/rtdata/languages/Nederlands index 4accd6424..3b854174e 100644 --- a/rtdata/languages/Nederlands +++ b/rtdata/languages/Nederlands @@ -1968,6 +1968,7 @@ ZOOMPANEL_ZOOMOUT;Zoom uit\nSneltoets: - !HISTORY_MSG_166;Exposure - Reset !HISTORY_MSG_412;Retinex - Scales !HISTORY_MSG_416;Retinex +!MAIN_BUTTON_SENDTOEDITOR;Edit image in external editor !TP_COLORTONING_STR;Strength !TP_DIRPYRDENOISE_CUR;Curve !TP_DIRPYRDENOISE_LAB;L*a*b* diff --git a/rtdata/languages/Polish b/rtdata/languages/Polish index fb8a07571..1e3702cbd 100644 --- a/rtdata/languages/Polish +++ b/rtdata/languages/Polish @@ -1650,6 +1650,7 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrót: - !HISTORY_MSG_424;Retinex - HL threshold !HISTORY_MSG_425;Retinex - Log base !HISTORY_MSG_426;Retinex - Hue equalizer +!MAIN_BUTTON_SENDTOEDITOR;Edit image in external editor !MAIN_TAB_INSPECT; Inspect !MAIN_TAB_WAVELET;Wavelet !MAIN_TAB_WAVELET_TOOLTIP;Shortcut: Alt-w diff --git a/rtdata/languages/Polish (Latin Characters) b/rtdata/languages/Polish (Latin Characters) index 8519cc04a..aa4edff85 100644 --- a/rtdata/languages/Polish (Latin Characters) +++ b/rtdata/languages/Polish (Latin Characters) @@ -1650,6 +1650,7 @@ ZOOMPANEL_ZOOMOUT;Oddal\nSkrot: - !HISTORY_MSG_424;Retinex - HL threshold !HISTORY_MSG_425;Retinex - Log base !HISTORY_MSG_426;Retinex - Hue equalizer +!MAIN_BUTTON_SENDTOEDITOR;Edit image in external editor !MAIN_TAB_INSPECT; Inspect !MAIN_TAB_WAVELET;Wavelet !MAIN_TAB_WAVELET_TOOLTIP;Shortcut: Alt-w diff --git a/rtdata/languages/Russian b/rtdata/languages/Russian index f86ff63c9..1748fd39a 100644 --- a/rtdata/languages/Russian +++ b/rtdata/languages/Russian @@ -1501,6 +1501,7 @@ ZOOMPANEL_ZOOMOUT;Удалить - !HISTORY_MSG_424;Retinex - HL threshold !HISTORY_MSG_425;Retinex - Log base !HISTORY_MSG_426;Retinex - Hue equalizer +!MAIN_BUTTON_SENDTOEDITOR;Edit image in external editor !MAIN_TAB_INSPECT; Inspect !MAIN_TAB_WAVELET;Wavelet !MAIN_TAB_WAVELET_TOOLTIP;Shortcut: Alt-w diff --git a/rtdata/languages/Swedish b/rtdata/languages/Swedish index db6512429..62416d9ee 100644 --- a/rtdata/languages/Swedish +++ b/rtdata/languages/Swedish @@ -1777,6 +1777,7 @@ ZOOMPANEL_ZOOMOUT;Förminska.\nKortkommando: - !HISTORY_MSG_424;Retinex - HL threshold !HISTORY_MSG_425;Retinex - Log base !HISTORY_MSG_426;Retinex - Hue equalizer +!MAIN_BUTTON_SENDTOEDITOR;Edit image in external editor !PARTIALPASTE_COLORTONING;Color toning !PARTIALPASTE_FLATFIELDCLIPCONTROL;Flat-field clip control !PARTIALPASTE_RETINEX;Retinex diff --git a/rtdata/languages/default b/rtdata/languages/default index b08fd8ca3..84586340e 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -708,6 +708,7 @@ MAIN_BUTTON_NAVSYNC_TOOLTIP;Synchronize the File Browser or Filmstrip with the E MAIN_BUTTON_PREFERENCES;Preferences MAIN_BUTTON_PUTTOQUEUE_TOOLTIP;Put current image to processing queue.\nShortcut: Ctrl+b MAIN_BUTTON_SAVE_TOOLTIP;Save current image.\nShortcut: Ctrl+s +MAIN_BUTTON_SENDTOEDITOR;Edit image in external editor MAIN_BUTTON_SENDTOEDITOR_TOOLTIP;Edit current image in external editor.\nShortcut: Ctrl+e MAIN_BUTTON_SHOWHIDESIDEPANELS_TOOLTIP;Show/hide all side panels.\nShortcut: m MAIN_BUTTON_UNFULLSCREEN;Exit fullscreen From 4272e2e16787fe6e6f05332a4f9a25e2a584ddf3 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Fri, 27 Nov 2015 23:19:45 +0100 Subject: [PATCH 02/11] Simlified use of StopWatch and included example into amaze demosaic --- rtengine/StopWatch.h | 6 ++++++ rtengine/amaze_demosaic_RT.cc | 2 ++ 2 files changed, 8 insertions(+) diff --git a/rtengine/StopWatch.h b/rtengine/StopWatch.h index fa043aa24..2b3ff1baf 100644 --- a/rtengine/StopWatch.h +++ b/rtengine/StopWatch.h @@ -24,6 +24,12 @@ #include #include "mytime.h" +#ifdef BENCHMARK + #define BENCHFUN StopWatch StopFun(__func__); +#else + #define BENCHFUN +#endif + class StopWatch { public: diff --git a/rtengine/amaze_demosaic_RT.cc b/rtengine/amaze_demosaic_RT.cc index dc2d4316e..46c77d7d7 100644 --- a/rtengine/amaze_demosaic_RT.cc +++ b/rtengine/amaze_demosaic_RT.cc @@ -31,12 +31,14 @@ #include "procparams.h" #include "sleef.c" #include "opthelper.h" +#include "StopWatch.h" namespace rtengine { SSEFUNCTION void RawImageSource::amaze_demosaic_RT(int winx, int winy, int winw, int winh) { + BENCHFUN #define HCLIP(x) x //is this still necessary??? //min(clip_pt,x) From 1ed09dc049bf192c0b06f4fe64641977a180ba6b Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sat, 28 Nov 2015 14:13:46 +0100 Subject: [PATCH 03/11] Fix leaking the axis adjusters in the coordinate adjuster. --- rtgui/coordinateadjuster.cc | 6 ++++++ rtgui/coordinateadjuster.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rtgui/coordinateadjuster.cc b/rtgui/coordinateadjuster.cc index 354e01577..61b5ae8b8 100644 --- a/rtgui/coordinateadjuster.cc +++ b/rtgui/coordinateadjuster.cc @@ -103,6 +103,12 @@ CoordinateAdjuster::CoordinateAdjuster(CoordinateProvider *provider, CurveEditor createWidgets(defaultAxis); } +CoordinateAdjuster::~CoordinateAdjuster() +{ + for (std::vector::iterator iterator = axisAdjusters.begin(); iterator != axisAdjusters.end(); ++iterator) + delete *iterator; +} + void CoordinateAdjuster::createWidgets(const std::vector &axis) { unsigned int count = axis.size(); diff --git a/rtgui/coordinateadjuster.h b/rtgui/coordinateadjuster.h index cb1eb91ed..8f00f8ae7 100644 --- a/rtgui/coordinateadjuster.h +++ b/rtgui/coordinateadjuster.h @@ -136,7 +136,7 @@ public: /// For more complex adjuster CoordinateAdjuster(CoordinateProvider *provider, CurveEditorSubGroup *parent, const std::vector &axis); - virtual ~CoordinateAdjuster() {} + virtual ~CoordinateAdjuster(); // Update the Axis list, e.g. on Curve change, but MUST have the same axis count void setAxis(const std::vector &axis); From e52ce5c485577290ba11a59f0368951192f85202 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sat, 28 Nov 2015 14:30:38 +0100 Subject: [PATCH 04/11] Replace a dubious manual return-value-optimization by a standard named-return-value-optimization to simplify leak detection. --- rtexif/rtexif.cc | 24 +++++++++++------------- rtexif/rtexif.h | 7 ++++--- rtgui/exifpanel.cc | 13 ++++++++----- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/rtexif/rtexif.cc b/rtexif/rtexif.cc index 2aa9c66e0..be442945d 100644 --- a/rtexif/rtexif.cc +++ b/rtexif/rtexif.cc @@ -2783,17 +2783,11 @@ TagDirectory* ExifManager::parseTIFF (FILE* f, bool skipIgnored) return parse (f, 0, skipIgnored); } -std::vector ExifManager::defTags; - -// forthis: the byte order will be taken from directory "forthis" -const std::vector& ExifManager::getDefaultTIFFTags (TagDirectory* forthis) +std::vector ExifManager::getDefaultTIFFTags (TagDirectory* forthis) { + std::vector defTags; - for (size_t i = 0; i < defTags.size(); i++) { - delete defTags[i]; - } - - defTags.clear (); + defTags.reserve (12); defTags.push_back (new Tag (forthis, lookupAttrib(ifdAttribs, "ImageWidth"), 0, LONG)); defTags.push_back (new Tag (forthis, lookupAttrib(ifdAttribs, "ImageHeight"), 0, LONG)); defTags.push_back (new Tag (forthis, lookupAttrib(ifdAttribs, "XResolution"), 300, RATIONAL)); @@ -2843,14 +2837,16 @@ int ExifManager::createJPEGMarker (const TagDirectory* root, const rtengine::pro cl->applyChange (i->first, i->second); } - getDefaultTIFFTags (cl); + const std::vector defTags = getDefaultTIFFTags (cl); defTags[0]->setInt (W, 0, LONG); defTags[1]->setInt (H, 0, LONG); defTags[8]->setInt (8, 0, SHORT); for (int i = defTags.size() - 1; i >= 0; i--) { - cl->replaceTag (defTags[i]->clone (cl)); + Tag* defTag = defTags[i]; + cl->replaceTag (defTag->clone (cl)); + delete defTag; } cl->sort (); @@ -2928,7 +2924,7 @@ int ExifManager::createTIFFHeader (const TagDirectory* root, const rtengine::pro } // append default properties - getDefaultTIFFTags (cl); + const std::vector defTags = getDefaultTIFFTags (cl); defTags[0]->setInt (W, 0, LONG); defTags[1]->setInt (H, 0, LONG); @@ -2939,7 +2935,9 @@ int ExifManager::createTIFFHeader (const TagDirectory* root, const rtengine::pro } for (int i = defTags.size() - 1; i >= 0; i--) { - cl->replaceTag (defTags[i]->clone (cl)); + Tag* defTag = defTags[i]; + cl->replaceTag (defTag->clone (cl)); + delete defTag; } // calculate strip offsets diff --git a/rtexif/rtexif.h b/rtexif/rtexif.h index f476445d1..d7c13f77a 100644 --- a/rtexif/rtexif.h +++ b/rtexif/rtexif.h @@ -306,8 +306,6 @@ public: class ExifManager { - static std::vector defTags; - static Tag* saveCIFFMNTag (FILE* f, TagDirectory* root, int len, const char* name); public: static TagDirectory* parse (FILE*f, int base, bool skipIgnored = true); @@ -316,7 +314,10 @@ public: static TagDirectory* parseCIFF (FILE* f, int base, int length); static void parseCIFF (FILE* f, int base, int length, TagDirectory* root); - static const std::vector& getDefaultTIFFTags (TagDirectory* forthis); + /// @brief Get default tag for TIFF + /// @param forthis The byte order will be taken from the given directory. + /// @return The ownership of the return tags is passed to the caller. + static std::vector getDefaultTIFFTags (TagDirectory* forthis); static int createJPEGMarker (const TagDirectory* root, const rtengine::procparams::ExifPairs& changeList, int W, int H, unsigned char* buffer); static int createTIFFHeader (const TagDirectory* root, const rtengine::procparams::ExifPairs& changeList, int W, int H, int bps, const char* profiledata, int profilelen, const char* iptcdata, int iptclen, unsigned char* buffer); }; diff --git a/rtgui/exifpanel.cc b/rtgui/exifpanel.cc index 9a8656592..8567183d1 100644 --- a/rtgui/exifpanel.cc +++ b/rtgui/exifpanel.cc @@ -156,14 +156,17 @@ void ExifPanel::setImageData (const ImageMetaData* id) idata = id; exifTreeModel->clear (); - const std::vector& defTags = ExifManager::getDefaultTIFFTags (NULL); + const std::vector defTags = ExifManager::getDefaultTIFFTags (NULL); - for (size_t i = 0; i < defTags.size(); i++) - if (defTags[i]->nameToString() == "ImageWidth" || defTags[i]->nameToString() == "ImageHeight" || defTags[i]->nameToString() == "BitsPerSample") { - addTag (exifTreeModel->children(), defTags[i]->nameToString(), "?", AC_SYSTEM, false); + for (size_t i = 0; i < defTags.size(); i++) { + Tag* defTag = defTags[i]; + if (defTag->nameToString() == "ImageWidth" || defTag->nameToString() == "ImageHeight" || defTag->nameToString() == "BitsPerSample") { + addTag (exifTreeModel->children(), defTag->nameToString(), "?", AC_SYSTEM, false); } else { - addTag (exifTreeModel->children(), defTags[i]->nameToString(), defTags[i]->valueToString(), AC_SYSTEM, false); + addTag (exifTreeModel->children(), defTag->nameToString(), defTag->valueToString(), AC_SYSTEM, false); } + delete defTag; + } if (id && id->getExifData ()) { // id->getExifData ()->printAll (); From 0611939c7a8ca81c16de11fa81cbce8b4c27707f Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sat, 28 Nov 2015 14:52:09 +0100 Subject: [PATCH 05/11] Remove apparently unused additional preview handler also fixing a memory leak. --- rtgui/editorpanel.cc | 1 - rtgui/editorpanel.h | 1 - 2 files changed, 2 deletions(-) diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 4d1907422..82e8d9fcf 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -516,7 +516,6 @@ void EditorPanel::open (Thumbnail* tmb, rtengine::InitialImage* isrc) lastSaveAsFileName = removeExtension (Glib::path_get_basename (fname)); previewHandler = new PreviewHandler (); - previewHandler2 = new PreviewHandler (); this->isrc = isrc; ipc = rtengine::StagedImageProcessor::create (isrc); diff --git a/rtgui/editorpanel.h b/rtgui/editorpanel.h index beb24a7c9..cf446da97 100644 --- a/rtgui/editorpanel.h +++ b/rtgui/editorpanel.h @@ -87,7 +87,6 @@ protected: ImageAreaPanel* iareapanel; PreviewHandler* previewHandler; PreviewHandler* beforePreviewHandler; // for the before-after view - PreviewHandler* previewHandler2; Navigator* navigator; ImageAreaPanel* beforeIarea; // for the before-after view Gtk::VBox* beforeBox; From f77ca41a6fa588371d9e88d7e868b8bb6a361f09 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Thu, 12 Nov 2015 22:26:24 +0100 Subject: [PATCH 06/11] Fix usage of the double-checked locking (anti-)pattern in the cache manager singleton. --- rtgui/cachemanager.cc | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/rtgui/cachemanager.cc b/rtgui/cachemanager.cc index 3d3702176..0b88ea5f4 100644 --- a/rtgui/cachemanager.cc +++ b/rtgui/cachemanager.cc @@ -30,18 +30,8 @@ CacheManager* CacheManager::getInstance(void) { - static CacheManager* instance_ = 0; - - if ( instance_ == 0 ) { - static MyMutex smutex_; - MyMutex::MyLock lock(smutex_); - - if ( instance_ == 0 ) { - instance_ = new CacheManager(); - } - } - - return instance_; + static CacheManager instance_; + return &instance_; } void CacheManager::init () From 9ec0557edf48ceb8681141e3688e915f53613356 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sat, 28 Nov 2015 12:31:43 +0100 Subject: [PATCH 07/11] Simplify the DCLP singleton instances found by searching for methods named 'getInstance'. --- rtengine/dcp.cc | 14 ++------------ rtengine/iccstore.cc | 14 ++------------ rtengine/lcp.cc | 14 ++------------ rtgui/extprog.cc | 14 ++------------ rtgui/previewloader.cc | 15 ++------------- rtgui/thumbimageupdater.cc | 10 ++-------- 6 files changed, 12 insertions(+), 69 deletions(-) diff --git a/rtengine/dcp.cc b/rtengine/dcp.cc index 9b3d852fc..9dd01330b 100644 --- a/rtengine/dcp.cc +++ b/rtengine/dcp.cc @@ -1691,18 +1691,8 @@ void DCPProfile::step2ApplyTile(float *rc, float *gc, float *bc, int width, int // Generates as singleton DCPStore* DCPStore::getInstance() { - static DCPStore* instance_ = 0; - - if ( instance_ == 0 ) { - static MyMutex smutex_; - MyMutex::MyLock lock(smutex_); - - if ( instance_ == 0 ) { - instance_ = new DCPStore(); - } - } - - return instance_; + static DCPStore instance_; + return &instance_; } // Reads all profiles from the given profiles dir diff --git a/rtengine/iccstore.cc b/rtengine/iccstore.cc index 195da3fe3..bad4e8dfa 100644 --- a/rtengine/iccstore.cc +++ b/rtengine/iccstore.cc @@ -192,18 +192,8 @@ ICCStore::makeStdGammaProfile(cmsHPROFILE iprof) ICCStore* ICCStore::getInstance(void) { - static ICCStore* instance_ = 0; - - if ( instance_ == 0 ) { - static MyMutex smutex_; - MyMutex::MyLock lock(smutex_); - - if ( instance_ == 0 ) { - instance_ = new ICCStore(); - } - } - - return instance_; + static ICCStore instance_; + return &instance_; } ICCStore::ICCStore () diff --git a/rtengine/lcp.cc b/rtengine/lcp.cc index da042711a..903e54a0a 100644 --- a/rtengine/lcp.cc +++ b/rtengine/lcp.cc @@ -781,18 +781,8 @@ void XMLCALL LCPProfile::XmlEndHandler(void *pLCPProfile, const char *el) // Generates as singleton LCPStore* LCPStore::getInstance() { - static LCPStore* instance_ = 0; - - if ( instance_ == 0 ) { - static MyMutex smutex_; - MyMutex::MyLock lock(smutex_); - - if ( instance_ == 0 ) { - instance_ = new LCPStore(); - } - } - - return instance_; + static LCPStore instance_; + return &instance_; } LCPProfile* LCPStore::getProfile (Glib::ustring filename) diff --git a/rtgui/extprog.cc b/rtgui/extprog.cc index 8e0ab225f..b6ef31255 100644 --- a/rtgui/extprog.cc +++ b/rtgui/extprog.cc @@ -74,18 +74,8 @@ bool ExtProgAction::Execute(std::vector fileNames) // Generates as singleton ExtProgStore* ExtProgStore::getInstance() { - static ExtProgStore* instance_ = 0; - - if ( instance_ == 0 ) { - static MyMutex smutex_; - MyMutex::MyLock lock(smutex_); - - if ( instance_ == 0 ) { - instance_ = new ExtProgStore(); - } - } - - return instance_; + static ExtProgStore instance_; + return &instance_; } ExtProgStore::~ExtProgStore() diff --git a/rtgui/previewloader.cc b/rtgui/previewloader.cc index 3fe1897ba..dd090a95e 100644 --- a/rtgui/previewloader.cc +++ b/rtgui/previewloader.cc @@ -168,19 +168,8 @@ PreviewLoader::PreviewLoader(): PreviewLoader* PreviewLoader::getInstance(void) { - // this will not be deleted... - static PreviewLoader* instance_ = NULL; - - if ( instance_ == NULL ) { - static MyMutex smutex_; - MyMutex::MyLock lock(smutex_); - - if ( instance_ == NULL ) { - instance_ = new PreviewLoader(); - } - } - - return instance_; + static PreviewLoader instance_; + return &instance_; } void PreviewLoader::add(int dir_id, const Glib::ustring& dir_entry, PreviewLoaderListener* l) diff --git a/rtgui/thumbimageupdater.cc b/rtgui/thumbimageupdater.cc index 3f5861677..29160236e 100644 --- a/rtgui/thumbimageupdater.cc +++ b/rtgui/thumbimageupdater.cc @@ -192,14 +192,8 @@ public: ThumbImageUpdater* ThumbImageUpdater::getInstance(void) { - // this will not be deleted... - static ThumbImageUpdater* instance_ = 0; - - if ( instance_ == 0 ) { - instance_ = new ThumbImageUpdater(); - } - - return instance_; + static ThumbImageUpdater instance_; + return &instance_; } ThumbImageUpdater::ThumbImageUpdater(): From ebe85388a3a3babdca8c2d11b18824b7ce46b9ab Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sat, 28 Nov 2015 12:48:06 +0100 Subject: [PATCH 08/11] Simplify the EditWindow singleton using an instance wrapper. --- rtgui/editwindow.cc | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/rtgui/editwindow.cc b/rtgui/editwindow.cc index 3b99f57e5..88bd2aee4 100644 --- a/rtgui/editwindow.cc +++ b/rtgui/editwindow.cc @@ -24,8 +24,6 @@ #include "rtimage.h" #include "threadutils.h" -static EditWindow* editWnd = NULL; - // Check if the system has more than one display and option is set bool EditWindow::isMultiDisplayEnabled() { @@ -35,29 +33,26 @@ bool EditWindow::isMultiDisplayEnabled() // Should only be created once, auto-creates window on correct display EditWindow* EditWindow::getInstance(RTWindow* p) { + struct EditWindowInstance + { + EditWindow editWnd; - if (editWnd == NULL) { - static MyMutex smutex_; - MyMutex::MyLock lock(smutex_); - - if ( editWnd == 0 ) { - editWnd = new EditWindow(p); - + EditWindowInstance(RTWindow* p) : editWnd(p) + { // Determine the other display and maximize the window on that const Glib::RefPtr< Gdk::Window >& wnd = p->get_window(); int monNo = p->get_screen()->get_monitor_at_window (wnd); Gdk::Rectangle lMonitorRect; - editWnd->get_screen()->get_monitor_geometry(isMultiDisplayEnabled() ? (monNo == 0 ? 1 : 0) : monNo, lMonitorRect); - editWnd->move(lMonitorRect.get_x(), lMonitorRect.get_y()); - editWnd->maximize(); - editWnd->show(); - } else { - editWnd->show_all(); + editWnd.get_screen()->get_monitor_geometry(isMultiDisplayEnabled() ? (monNo == 0 ? 1 : 0) : monNo, lMonitorRect); + editWnd.move(lMonitorRect.get_x(), lMonitorRect.get_y()); + editWnd.maximize(); } - } + }; - return editWnd; + static EditWindowInstance instance_(p); + instance_.editWnd.show_all(); + return &instance_.editWnd; } EditWindow::EditWindow (RTWindow* p) : parent(p) , isFullscreen(false) From 68271b92794ca236978c76072105eca60940979f Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sat, 28 Nov 2015 12:54:03 +0100 Subject: [PATCH 09/11] Regularize the camera constant store singleton to use a function local static like most other singletons. --- rtengine/camconst.cc | 17 +++++------------ rtengine/camconst.h | 2 +- rtengine/init.cc | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/rtengine/camconst.cc b/rtengine/camconst.cc index 80d73ea2e..e45a332e1 100644 --- a/rtengine/camconst.cc +++ b/rtengine/camconst.cc @@ -683,29 +683,22 @@ CameraConstantsStore::CameraConstantsStore() { } -static CameraConstantsStore *global_instance; - -void CameraConstantsStore::initCameraConstants(Glib::ustring baseDir, Glib::ustring userSettingsDir) +void CameraConstantsStore::init(Glib::ustring baseDir, Glib::ustring userSettingsDir) { - if (global_instance) { - // should only be called once during init. - abort(); - } - - global_instance = new CameraConstantsStore(); - global_instance->parse_camera_constants_file(Glib::build_filename(baseDir, "camconst.json")); + parse_camera_constants_file(Glib::build_filename(baseDir, "camconst.json")); Glib::ustring userFile(Glib::build_filename(userSettingsDir, "camconst.json")); if (safe_file_test(userFile, Glib::FILE_TEST_EXISTS)) { - global_instance->parse_camera_constants_file(userFile); + parse_camera_constants_file(userFile); } } CameraConstantsStore * CameraConstantsStore::getInstance(void) { - return global_instance; + static CameraConstantsStore instance_; + return &instance_; } CameraConst * diff --git a/rtengine/camconst.h b/rtengine/camconst.h index a591f09fe..b57c3fee9 100644 --- a/rtengine/camconst.h +++ b/rtengine/camconst.h @@ -54,7 +54,7 @@ private: bool parse_camera_constants_file(Glib::ustring filename); public: - static void initCameraConstants(Glib::ustring baseDir, Glib::ustring userSettingsDir); + void init(Glib::ustring baseDir, Glib::ustring userSettingsDir); static CameraConstantsStore *getInstance(void); CameraConst *get(const char make[], const char model[]); }; diff --git a/rtengine/init.cc b/rtengine/init.cc index acedd844f..9fa5c48ee 100644 --- a/rtengine/init.cc +++ b/rtengine/init.cc @@ -46,7 +46,7 @@ int init (const Settings* s, Glib::ustring baseDir, Glib::ustring userSettingsDi dcpStore->init (baseDir + "/dcpprofiles"); - CameraConstantsStore::initCameraConstants (baseDir, userSettingsDir); + CameraConstantsStore::getInstance ()->init (baseDir, userSettingsDir); profileStore.init (); ProcParams::init (); Color::init (); From 286b8e7f67d261a051438c6fe1bf259f7cc0ce57 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sat, 28 Nov 2015 22:40:22 +0100 Subject: [PATCH 10/11] Fix trying to dereference invalid iterator in ExifPanel::editTag. --- rtgui/exifpanel.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rtgui/exifpanel.cc b/rtgui/exifpanel.cc index 8567183d1..987cd42d7 100644 --- a/rtgui/exifpanel.cc +++ b/rtgui/exifpanel.cc @@ -499,6 +499,9 @@ void ExifPanel::editTag (Gtk::TreeModel::Children root, Glib::ustring name, Glib } } + if (iter == root.end()) + return; + if (dp == Glib::ustring::npos) { if (value == "#keep" && iter->get_value (exifColumns.action) != AC_SYSTEM) { iter->set_value (exifColumns.icon, iter->get_value (exifColumns.edited) ? editicon : keepicon); From 39ef59ddeb7679c71274b1da3faadd395b650c73 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sun, 29 Nov 2015 11:48:30 +0100 Subject: [PATCH 11/11] Build with '-std=c++11' if libsigc++ version 2.5.1 is used as it does require it. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd5fcbc63..615348484 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -278,10 +278,10 @@ if (OPTION_OMP) endif (OPENMP_FOUND) endif (OPTION_OMP) -if(USE_EXPERIMENTAL_LANG_VERSIONS) +if(USE_EXPERIMENTAL_LANG_VERSIONS OR NOT (SIGC_VERSION VERSION_LESS 2.5.1)) SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu1x") SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x") -endif (USE_EXPERIMENTAL_LANG_VERSIONS) +endif () # find out whether we are building out of source get_filename_component(ABS_SOURCE_DIR "${PROJECT_SOURCE_DIR}" ABSOLUTE)