From 8a3298ebb807ff70620581d6ca49c5984a013321 Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 2 Nov 2012 16:58:13 +0000 Subject: [PATCH] Added a PropertiesFile::reload() method. --- .../app_properties/juce_PropertiesFile.cpp | 9 +++++---- .../app_properties/juce_PropertiesFile.h | 4 +++- modules/juce_graphics/native/juce_RenderingHelpers.h | 4 +--- .../native/juce_ios_UIViewComponentPeer.mm | 8 ++------ 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp b/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp index 315e96d855..fdc68b8cc3 100644 --- a/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp +++ b/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp @@ -108,7 +108,7 @@ PropertiesFile::PropertiesFile (const File& f, const Options& o) file (f), options (o), loadedOk (false), needsWriting (false) { - initialise(); + reload(); } PropertiesFile::PropertiesFile (const Options& o) @@ -116,17 +116,18 @@ PropertiesFile::PropertiesFile (const Options& o) file (o.getDefaultFile()), options (o), loadedOk (false), needsWriting (false) { - initialise(); + reload(); } -void PropertiesFile::initialise() +bool PropertiesFile::reload() { ProcessScopedLock pl (createProcessLock()); if (pl != nullptr && ! pl->isLocked()) - return; // locking failure.. + return false; // locking failure.. loadedOk = (! file.exists()) || loadAsBinary() || loadAsXml(); + return loadedOk; } PropertiesFile::~PropertiesFile() diff --git a/modules/juce_data_structures/app_properties/juce_PropertiesFile.h b/modules/juce_data_structures/app_properties/juce_PropertiesFile.h index d501d9950a..ac3aecbc3a 100644 --- a/modules/juce_data_structures/app_properties/juce_PropertiesFile.h +++ b/modules/juce_data_structures/app_properties/juce_PropertiesFile.h @@ -210,6 +210,9 @@ public: */ void setNeedsToBeSaved (bool needsToBeSaved); + /** Attempts to reload the settings from the file. */ + bool reload(); + //============================================================================== /** Returns the file that's being used. */ const File& getFile() const noexcept { return file; } @@ -229,7 +232,6 @@ private: InterProcessLock::ScopedLockType* createProcessLock() const; void timerCallback(); - void initialise(); bool saveAsXml(); bool saveAsBinary(); bool loadAsXml(); diff --git a/modules/juce_graphics/native/juce_RenderingHelpers.h b/modules/juce_graphics/native/juce_RenderingHelpers.h index 4f21b7d5ef..11b4653248 100644 --- a/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -2506,9 +2506,7 @@ public: void restore() { - StateObjectType* const top = stack.getLast(); - - if (top != nullptr) + if (StateObjectType* const top = stack.getLast()) { currentState = top; stack.removeLast (1, false); diff --git a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index b57e4f3bca..368cc89f2b 100644 --- a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -877,9 +877,7 @@ void UIViewComponentPeer::updateHiddenTextContent (TextInputTarget* target) BOOL UIViewComponentPeer::textViewReplaceCharacters (const Range& range, const String& text) { - TextInputTarget* const target = findCurrentTextInputTarget(); - - if (target != nullptr) + if (TextInputTarget* const target = findCurrentTextInputTarget()) { const Range currentSelection (target->getHighlightedRegion()); @@ -900,9 +898,7 @@ BOOL UIViewComponentPeer::textViewReplaceCharacters (const Range& range, co void UIViewComponentPeer::globalFocusChanged (Component*) { - TextInputTarget* const target = findCurrentTextInputTarget(); - - if (target != nullptr) + if (TextInputTarget* const target = findCurrentTextInputTarget()) { Component* comp = dynamic_cast (target);