1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added a PropertiesFile::reload() method.

This commit is contained in:
jules 2012-11-02 16:58:13 +00:00
parent 793fec6592
commit 8a3298ebb8
4 changed files with 11 additions and 14 deletions

View file

@ -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()

View file

@ -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();

View file

@ -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);

View file

@ -877,9 +877,7 @@ void UIViewComponentPeer::updateHiddenTextContent (TextInputTarget* target)
BOOL UIViewComponentPeer::textViewReplaceCharacters (const Range<int>& range, const String& text)
{
TextInputTarget* const target = findCurrentTextInputTarget();
if (target != nullptr)
if (TextInputTarget* const target = findCurrentTextInputTarget())
{
const Range<int> currentSelection (target->getHighlightedRegion());
@ -900,9 +898,7 @@ BOOL UIViewComponentPeer::textViewReplaceCharacters (const Range<int>& range, co
void UIViewComponentPeer::globalFocusChanged (Component*)
{
TextInputTarget* const target = findCurrentTextInputTarget();
if (target != nullptr)
if (TextInputTarget* const target = findCurrentTextInputTarget())
{
Component* comp = dynamic_cast<Component*> (target);