Browse Source

Added safeguard for ScopedPointer and fix for PropertiesFile locks.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
e6237b5154
5 changed files with 26 additions and 18 deletions
  1. +6
    -6
      juce_amalgamated.cpp
  2. +7
    -3
      juce_amalgamated.h
  3. +4
    -0
      src/containers/juce_ScopedPointer.h
  4. +6
    -6
      src/utilities/juce_PropertiesFile.cpp
  5. +3
    -3
      src/utilities/juce_PropertiesFile.h

+ 6
- 6
juce_amalgamated.cpp View File

@@ -17635,7 +17635,7 @@ PropertiesFile::PropertiesFile (const File& f, const int millisecondsBeforeSavin
|| (options_ & (storeAsBinary | storeAsCompressedBinary | storeAsXML)) == storeAsCompressedBinary
|| (options_ & (storeAsBinary | storeAsCompressedBinary | storeAsXML)) == storeAsXML);

ProcessScopedLock pl (getProcessLock());
ProcessScopedLock pl (createProcessLock());

ScopedPointer<InputStream> fileStream (f.createInputStream());

@@ -17717,9 +17717,9 @@ PropertiesFile::~PropertiesFile()
jassertfalse;
}

PropertiesFile::ProcessScopedLock PropertiesFile::getProcessLock() const
InterProcessLock::ScopedLockType* PropertiesFile::createProcessLock() const
{
return ProcessScopedLock (processLock != 0 ? new InterProcessLock::ScopedLockType (*processLock) : 0);
return processLock != 0 ? new InterProcessLock::ScopedLockType (*processLock) : 0;
}

bool PropertiesFile::saveIfNeeded()
@@ -17771,7 +17771,7 @@ bool PropertiesFile::save()
getAllProperties().getAllValues() [i]);
}

ProcessScopedLock pl (getProcessLock());
ProcessScopedLock pl (createProcessLock());

if (doc.writeToFile (file, String::empty))
{
@@ -17781,7 +17781,7 @@ bool PropertiesFile::save()
}
else
{
ProcessScopedLock pl (getProcessLock());
ProcessScopedLock pl (createProcessLock());

TemporaryFile tempFile (file);
ScopedPointer <OutputStream> out (tempFile.getFile().createOutputStream());
@@ -17887,7 +17887,7 @@ PropertiesFile* PropertiesFile::createDefaultAppPropertiesFile (const String& ap
const bool commonToAllUsers,
const int millisecondsBeforeSaving,
const int propertiesFileOptions,
InterProcessLock *processLock_)
InterProcessLock* processLock_)
{
const File file (getDefaultAppSettingsFile (applicationName,
fileNameSuffix,


+ 7
- 3
juce_amalgamated.h View File

@@ -3484,6 +3484,10 @@ private:

// (Required as an alternative to the overloaded & operator).
const ScopedPointer* getAddress() const throw() { return this; }

// This is private to stop people accidentally copying a const ScopedPointer (the compiler
// will let you do so by implicitly casting the source to its raw object pointer).
ScopedPointer (const ScopedPointer&);
};

template <class ObjectType>
@@ -13480,7 +13484,7 @@ public:
bool commonToAllUsers,
int millisecondsBeforeSaving,
int propertiesFileOptions,
InterProcessLock *ipl = NULL);
InterProcessLock* processLock = 0);

static const File getDefaultAppSettingsFile (const String& applicationName,
const String& fileNameSuffix,
@@ -13500,8 +13504,8 @@ private:
bool loadedOk, needsWriting;

InterProcessLock* processLock;
typedef ScopedPointer<InterProcessLock::ScopedLockType> ProcessScopedLock;
ProcessScopedLock getProcessLock() const;
typedef const ScopedPointer<InterProcessLock::ScopedLockType> ProcessScopedLock;
InterProcessLock::ScopedLockType* createProcessLock() const;

void timerCallback();



+ 4
- 0
src/containers/juce_ScopedPointer.h View File

@@ -166,6 +166,10 @@ private:
// (Required as an alternative to the overloaded & operator).
const ScopedPointer* getAddress() const throw() { return this; }
// This is private to stop people accidentally copying a const ScopedPointer (the compiler
// will let you do so by implicitly casting the source to its raw object pointer).
ScopedPointer (const ScopedPointer&);
};
//==============================================================================


+ 6
- 6
src/utilities/juce_PropertiesFile.cpp View File

@@ -69,7 +69,7 @@ PropertiesFile::PropertiesFile (const File& f, const int millisecondsBeforeSavin
|| (options_ & (storeAsBinary | storeAsCompressedBinary | storeAsXML)) == storeAsCompressedBinary
|| (options_ & (storeAsBinary | storeAsCompressedBinary | storeAsXML)) == storeAsXML);
ProcessScopedLock pl (getProcessLock());
ProcessScopedLock pl (createProcessLock());
ScopedPointer<InputStream> fileStream (f.createInputStream());
@@ -151,9 +151,9 @@ PropertiesFile::~PropertiesFile()
jassertfalse;
}
PropertiesFile::ProcessScopedLock PropertiesFile::getProcessLock() const
InterProcessLock::ScopedLockType* PropertiesFile::createProcessLock() const
{
return ProcessScopedLock (processLock != 0 ? new InterProcessLock::ScopedLockType (*processLock) : 0);
return processLock != 0 ? new InterProcessLock::ScopedLockType (*processLock) : 0;
}
bool PropertiesFile::saveIfNeeded()
@@ -205,7 +205,7 @@ bool PropertiesFile::save()
getAllProperties().getAllValues() [i]);
}
ProcessScopedLock pl (getProcessLock());
ProcessScopedLock pl (createProcessLock());
if (doc.writeToFile (file, String::empty))
{
@@ -215,7 +215,7 @@ bool PropertiesFile::save()
}
else
{
ProcessScopedLock pl (getProcessLock());
ProcessScopedLock pl (createProcessLock());
TemporaryFile tempFile (file);
ScopedPointer <OutputStream> out (tempFile.getFile().createOutputStream());
@@ -322,7 +322,7 @@ PropertiesFile* PropertiesFile::createDefaultAppPropertiesFile (const String& ap
const bool commonToAllUsers,
const int millisecondsBeforeSaving,
const int propertiesFileOptions,
InterProcessLock *processLock_)
InterProcessLock* processLock_)
{
const File file (getDefaultAppSettingsFile (applicationName,
fileNameSuffix,


+ 3
- 3
src/utilities/juce_PropertiesFile.h View File

@@ -155,7 +155,7 @@ public:
bool commonToAllUsers,
int millisecondsBeforeSaving,
int propertiesFileOptions,
InterProcessLock *ipl = NULL);
InterProcessLock* processLock = 0);
/** Handy utility to choose a file in the standard OS-dependent location for application
settings files.
@@ -197,8 +197,8 @@ private:
bool loadedOk, needsWriting;
InterProcessLock* processLock;
typedef ScopedPointer<InterProcessLock::ScopedLockType> ProcessScopedLock;
ProcessScopedLock getProcessLock() const;
typedef const ScopedPointer<InterProcessLock::ScopedLockType> ProcessScopedLock;
InterProcessLock::ScopedLockType* createProcessLock() const;
void timerCallback();


Loading…
Cancel
Save