Browse Source

Removed a few more places where static objects could cause problems for people who do unwise amounts of work in their static constructors.

tags/2021-05-28
jules 11 years ago
parent
commit
a316bd5f6f
21 changed files with 44 additions and 44 deletions
  1. +1
    -1
      extras/Introjucer/Source/Utility/jucer_MiscUtilities.h
  2. +1
    -1
      modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp
  3. +4
    -4
      modules/juce_browser_plugin_client/wrapper/juce_ActiveX_GlueCode.cpp
  4. +1
    -1
      modules/juce_browser_plugin_client/wrapper/juce_NPAPI_GlueCode.cpp
  5. +1
    -1
      modules/juce_core/containers/juce_PropertySet.cpp
  6. +2
    -2
      modules/juce_core/files/juce_File.cpp
  7. +2
    -2
      modules/juce_core/files/juce_TemporaryFile.cpp
  8. +7
    -7
      modules/juce_core/javascript/juce_JSON.cpp
  9. +1
    -1
      modules/juce_core/javascript/juce_Javascript.cpp
  10. +1
    -1
      modules/juce_core/native/juce_android_Files.cpp
  11. +2
    -2
      modules/juce_core/native/juce_linux_Files.cpp
  12. +1
    -1
      modules/juce_core/native/juce_mac_Files.mm
  13. +2
    -2
      modules/juce_core/native/juce_win32_Files.cpp
  14. +1
    -1
      modules/juce_core/time/juce_PerformanceCounter.cpp
  15. +1
    -1
      modules/juce_core/time/juce_PerformanceCounter.h
  16. +3
    -3
      modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp
  17. +9
    -9
      modules/juce_data_structures/values/juce_ValueTree.cpp
  18. +1
    -1
      modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp
  19. +1
    -1
      modules/juce_gui_basics/widgets/juce_ListBox.cpp
  20. +1
    -1
      modules/juce_gui_basics/widgets/juce_TableListBox.cpp
  21. +1
    -1
      modules/juce_gui_basics/widgets/juce_TreeView.cpp

+ 1
- 1
extras/Introjucer/Source/Utility/jucer_MiscUtilities.h View File

@@ -231,7 +231,7 @@ public:
if (getColour() != newColour) if (getColour() != newColour)
{ {
if (newColour == defaultColour && defaultButton.isVisible()) if (newColour == defaultColour && defaultButton.isVisible())
colourValue = var::null;
colourValue = var();
else else
colourValue = newColour.toDisplayString (true); colourValue = newColour.toDisplayString (true);
} }


+ 1
- 1
modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp View File

@@ -120,7 +120,7 @@ bool PluginDirectoryScanner::skipNextFile()
void PluginDirectoryScanner::setDeadMansPedalFile (const StringArray& newContents) void PluginDirectoryScanner::setDeadMansPedalFile (const StringArray& newContents)
{ {
if (deadMansPedalFile != File::nonexistent)
if (deadMansPedalFile.getFullPathName().isNotEmpty())
deadMansPedalFile.replaceWithText (newContents.joinIntoString ("\n"), true, true); deadMansPedalFile.replaceWithText (newContents.joinIntoString ("\n"), true, true);
} }


+ 4
- 4
modules/juce_browser_plugin_client/wrapper/juce_ActiveX_GlueCode.cpp View File

@@ -252,7 +252,7 @@ public:
} }
} }
return var::null;
return var();
} }
bool hasProperty (const Identifier& propertyName) const override bool hasProperty (const Identifier& propertyName) const override
@@ -297,7 +297,7 @@ public:
void removeProperty (const Identifier& propertyName) override void removeProperty (const Identifier& propertyName) override
{ {
setProperty (propertyName, var::null);
setProperty (propertyName, var());
} }
bool hasMethod (const Identifier& methodName) const override bool hasMethod (const Identifier& methodName) const override
@@ -401,7 +401,7 @@ var variantTojuceVar (const VARIANT& v)
switch (v.vt & ~VT_BYREF) switch (v.vt & ~VT_BYREF)
{ {
case VT_VOID: case VT_VOID:
case VT_EMPTY: return var::null;
case VT_EMPTY: return var();
case VT_I1: return var ((int) v.cVal); case VT_I1: return var ((int) v.cVal);
case VT_I2: return var ((int) v.iVal); case VT_I2: return var ((int) v.iVal);
case VT_I4: return var ((int) v.lVal); case VT_I4: return var ((int) v.lVal);
@@ -421,7 +421,7 @@ var variantTojuceVar (const VARIANT& v)
} }
} }
return var::null;
return var();
} }
//============================================================================== //==============================================================================


+ 1
- 1
modules/juce_browser_plugin_client/wrapper/juce_NPAPI_GlueCode.cpp View File

@@ -896,7 +896,7 @@ static var createValueFromNPVariant (NPP npp, const NPVariant& v)
else if (NPVARIANT_IS_OBJECT (v) && npp != nullptr) else if (NPVARIANT_IS_OBJECT (v) && npp != nullptr)
return var (new DynamicObjectWrappingNPObject (npp, NPVARIANT_TO_OBJECT (v))); return var (new DynamicObjectWrappingNPObject (npp, NPVARIANT_TO_OBJECT (v)));
return var::null;
return var();
} }
static void createNPVariantFromValue (NPP npp, NPVariant& out, const var& v) static void createNPVariantFromValue (NPP npp, NPVariant& out, const var& v)


+ 1
- 1
modules/juce_core/containers/juce_PropertySet.cpp View File

@@ -155,7 +155,7 @@ void PropertySet::removeValue (StringRef keyName)
void PropertySet::setValue (const String& keyName, const XmlElement* const xml) void PropertySet::setValue (const String& keyName, const XmlElement* const xml)
{ {
setValue (keyName, xml == nullptr ? var::null
setValue (keyName, xml == nullptr ? var()
: var (xml->createDocument ("", true))); : var (xml->createDocument ("", true)));
} }


+ 2
- 2
modules/juce_core/files/juce_File.cpp View File

@@ -322,7 +322,7 @@ String File::getFileNameWithoutExtension() const
bool File::isAChildOf (const File& potentialParent) const bool File::isAChildOf (const File& potentialParent) const
{ {
if (potentialParent == File::nonexistent)
if (potentialParent.fullPath.isEmpty())
return false; return false;
const String ourPath (getPathUpToLastSlash()); const String ourPath (getPathUpToLastSlash());
@@ -629,7 +629,7 @@ bool File::hasFileExtension (StringRef possibleSuffix) const
File File::withFileExtension (StringRef newExtension) const File File::withFileExtension (StringRef newExtension) const
{ {
if (fullPath.isEmpty()) if (fullPath.isEmpty())
return File::nonexistent;
return File();
String filePart (getFileName()); String filePart (getFileName());


+ 2
- 2
modules/juce_core/files/juce_TemporaryFile.cpp View File

@@ -50,7 +50,7 @@ TemporaryFile::TemporaryFile (const File& target, const int optionFlags)
targetFile (target) targetFile (target)
{ {
// If you use this constructor, you need to give it a valid target file! // If you use this constructor, you need to give it a valid target file!
jassert (targetFile != File::nonexistent);
jassert (targetFile != File());
} }
TemporaryFile::TemporaryFile (const File& target, const File& temporary) TemporaryFile::TemporaryFile (const File& target, const File& temporary)
@@ -79,7 +79,7 @@ bool TemporaryFile::overwriteTargetFileWithTemporary() const
{ {
// This method only works if you created this object with the constructor // This method only works if you created this object with the constructor
// that takes a target file! // that takes a target file!
jassert (targetFile != File::nonexistent);
jassert (targetFile != File());
if (temporaryFile.exists()) if (temporaryFile.exists())
{ {


+ 7
- 7
modules/juce_core/javascript/juce_JSON.cpp View File

@@ -35,7 +35,7 @@ public:
switch (t.getAndAdvance()) switch (t.getAndAdvance())
{ {
case 0: result = var::null; return Result::ok();
case 0: result = var(); return Result::ok();
case '{': return parseObject (t, result); case '{': return parseObject (t, result);
case '[': return parseArray (t, result); case '[': return parseArray (t, result);
} }
@@ -148,7 +148,7 @@ private:
if (t2.getAndAdvance() == 'u' && t2.getAndAdvance() == 'l' && t2.getAndAdvance() == 'l') if (t2.getAndAdvance() == 'u' && t2.getAndAdvance() == 'l' && t2.getAndAdvance() == 'l')
{ {
t = t2; t = t2;
result = var::null;
result = var();
return Result::ok(); return Result::ok();
} }
break; break;
@@ -254,7 +254,7 @@ private:
if (c2 != ':') if (c2 != ':')
return createFail ("Expected ':', but found", &oldT); return createFail ("Expected ':', but found", &oldT);
resultProperties.set (propertyName, var::null);
resultProperties.set (propertyName, var());
var* propertyValue = resultProperties.getVarPointer (propertyName); var* propertyValue = resultProperties.getVarPointer (propertyName);
Result r2 (parseAny (t, *propertyValue)); Result r2 (parseAny (t, *propertyValue));
@@ -300,7 +300,7 @@ private:
return createFail ("Unexpected end-of-input in array declaration"); return createFail ("Unexpected end-of-input in array declaration");
t = oldT; t = oldT;
destArray->add (var::null);
destArray->add (var());
Result r (parseAny (t, destArray->getReference (destArray->size() - 1))); Result r (parseAny (t, destArray->getReference (destArray->size() - 1)));
if (r.failed()) if (r.failed())
@@ -514,7 +514,7 @@ var JSON::parse (const String& text)
var result; var result;
if (! JSONParser::parseObjectOrArray (text.getCharPointer(), result)) if (! JSONParser::parseObjectOrArray (text.getCharPointer(), result))
result = var::null;
result = var();
return result; return result;
} }
@@ -610,7 +610,7 @@ public:
{ {
switch (r.nextInt (depth > 3 ? 6 : 8)) switch (r.nextInt (depth > 3 ? 6 : 8))
{ {
case 0: return var::null;
case 0: return var();
case 1: return r.nextInt(); case 1: return r.nextInt();
case 2: return r.nextInt64(); case 2: return r.nextInt64();
case 3: return r.nextBool(); case 3: return r.nextBool();
@@ -638,7 +638,7 @@ public:
} }
default: default:
return var::null;
return var();
} }
} }


+ 1
- 1
modules/juce_core/javascript/juce_Javascript.cpp View File

@@ -1244,7 +1244,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
if (matchIf (TokenTypes::openParen)) return parseSuffixes (matchCloseParen (parseExpression())); if (matchIf (TokenTypes::openParen)) return parseSuffixes (matchCloseParen (parseExpression()));
if (matchIf (TokenTypes::true_)) return parseSuffixes (new LiteralValue (location, (int) 1)); if (matchIf (TokenTypes::true_)) return parseSuffixes (new LiteralValue (location, (int) 1));
if (matchIf (TokenTypes::false_)) return parseSuffixes (new LiteralValue (location, (int) 0)); if (matchIf (TokenTypes::false_)) return parseSuffixes (new LiteralValue (location, (int) 0));
if (matchIf (TokenTypes::null_)) return parseSuffixes (new LiteralValue (location, var::null));
if (matchIf (TokenTypes::null_)) return parseSuffixes (new LiteralValue (location, var()));
if (matchIf (TokenTypes::undefined)) return parseSuffixes (new Expression (location)); if (matchIf (TokenTypes::undefined)) return parseSuffixes (new Expression (location));
if (currentType == TokenTypes::literal) if (currentType == TokenTypes::literal)


+ 1
- 1
modules/juce_core/native/juce_android_Files.cpp View File

@@ -80,7 +80,7 @@ File File::getSpecialLocation (const SpecialLocationType type)
break; break;
} }
return File::nonexistent;
return File();
} }
bool File::moveToTrash() const bool File::moveToTrash() const


+ 2
- 2
modules/juce_core/native/juce_linux_Files.cpp View File

@@ -115,7 +115,7 @@ File File::getSpecialLocation (const SpecialLocationType type)
if (struct passwd* const pw = getpwuid (getuid())) if (struct passwd* const pw = getpwuid (getuid()))
return File (CharPointer_UTF8 (pw->pw_dir)); return File (CharPointer_UTF8 (pw->pw_dir));
return File::nonexistent;
return File();
} }
case userDocumentsDirectory: return resolveXDGFolder ("XDG_DOCUMENTS_DIR", "~"); case userDocumentsDirectory: return resolveXDGFolder ("XDG_DOCUMENTS_DIR", "~");
@@ -163,7 +163,7 @@ File File::getSpecialLocation (const SpecialLocationType type)
break; break;
} }
return File::nonexistent;
return File();
} }
//============================================================================== //==============================================================================


+ 1
- 1
modules/juce_core/native/juce_mac_Files.mm View File

@@ -257,7 +257,7 @@ File File::getSpecialLocation (const SpecialLocationType type)
return File (resultPath.convertToPrecomposedUnicode()); return File (resultPath.convertToPrecomposedUnicode());
} }
return File::nonexistent;
return File();
} }
//============================================================================== //==============================================================================


+ 2
- 2
modules/juce_core/native/juce_win32_Files.cpp View File

@@ -93,7 +93,7 @@ namespace WindowsFileHelpers
if (SHGetSpecialFolderPath (0, path, type, FALSE)) if (SHGetSpecialFolderPath (0, path, type, FALSE))
return File (String (path)); return File (String (path));
return File::nonexistent;
return File();
} }
File getModuleFileName (HINSTANCE moduleHandle) File getModuleFileName (HINSTANCE moduleHandle)
@@ -542,7 +542,7 @@ File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType type)
default: default:
jassertfalse; // unknown type? jassertfalse; // unknown type?
return File::nonexistent;
return File();
} }
return WindowsFileHelpers::getSpecialFolderPath (csidlType); return WindowsFileHelpers::getSpecialFolderPath (csidlType);


+ 1
- 1
modules/juce_core/time/juce_PerformanceCounter.cpp View File

@@ -28,7 +28,7 @@
static void appendToFile (const File& f, const String& s) static void appendToFile (const File& f, const String& s)
{ {
if (f != File::nonexistent)
if (f.getFullPathName().isNotEmpty())
{ {
FileOutputStream out (f); FileOutputStream out (f);


+ 1
- 1
modules/juce_core/time/juce_PerformanceCounter.h View File

@@ -65,7 +65,7 @@ public:
*/ */
PerformanceCounter (const String& counterName, PerformanceCounter (const String& counterName,
int runsPerPrintout = 100, int runsPerPrintout = 100,
const File& loggingFile = File::nonexistent);
const File& loggingFile = File());
/** Destructor. */ /** Destructor. */
~PerformanceCounter(); ~PerformanceCounter();


+ 3
- 3
modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp View File

@@ -90,8 +90,8 @@ File PropertiesFile::Options::getDefaultFile() const
File dir (File::getSpecialLocation (commonToAllUsers ? File::commonApplicationDataDirectory File dir (File::getSpecialLocation (commonToAllUsers ? File::commonApplicationDataDirectory
: File::userApplicationDataDirectory)); : File::userApplicationDataDirectory));
if (dir == File::nonexistent)
return File::nonexistent;
if (dir == File())
return File();
dir = dir.getChildFile (folderName.isNotEmpty() ? folderName dir = dir.getChildFile (folderName.isNotEmpty() ? folderName
: applicationName); : applicationName);
@@ -165,7 +165,7 @@ bool PropertiesFile::save()
stopTimer(); stopTimer();
if (options.doNotSave if (options.doNotSave
|| file == File::nonexistent
|| file == File()
|| file.isDirectory() || file.isDirectory()
|| ! file.getParentDirectory().createDirectory()) || ! file.getParentDirectory().createDirectory())
return false; return false;


+ 9
- 9
modules/juce_data_structures/values/juce_ValueTree.cpp View File

@@ -168,7 +168,7 @@ public:
} }
else else
{ {
undoManager->perform (new SetPropertyAction (this, name, newValue, var::null, true, false));
undoManager->perform (new SetPropertyAction (this, name, newValue, var(), true, false));
} }
} }
} }
@@ -188,7 +188,7 @@ public:
else else
{ {
if (properties.contains (name)) if (properties.contains (name))
undoManager->perform (new SetPropertyAction (this, name, var::null, properties [name], false, true));
undoManager->perform (new SetPropertyAction (this, name, var(), properties [name], false, true));
} }
} }
@@ -206,7 +206,7 @@ public:
else else
{ {
for (int i = properties.size(); --i >= 0;) for (int i = properties.size(); --i >= 0;)
undoManager->perform (new SetPropertyAction (this, properties.getName(i), var::null,
undoManager->perform (new SetPropertyAction (this, properties.getName(i), var(),
properties.getValueAt(i), false, true)); properties.getValueAt(i), false, true));
} }
} }
@@ -230,7 +230,7 @@ public:
return ValueTree (s); return ValueTree (s);
} }
return ValueTree::invalid;
return ValueTree();
} }
ValueTree getOrCreateChildWithName (const Identifier typeToMatch, UndoManager* undoManager) ValueTree getOrCreateChildWithName (const Identifier typeToMatch, UndoManager* undoManager)
@@ -257,7 +257,7 @@ public:
return ValueTree (s); return ValueTree (s);
} }
return ValueTree::invalid;
return ValueTree();
} }
bool isAChildOf (const SharedObject* const possibleParent) const noexcept bool isAChildOf (const SharedObject* const possibleParent) const noexcept
@@ -846,17 +846,17 @@ ValueTree ValueTree::getChild (int index) const
ValueTree ValueTree::getChildWithName (const Identifier type) const ValueTree ValueTree::getChildWithName (const Identifier type) const
{ {
return object != nullptr ? object->getChildWithName (type) : ValueTree::invalid;
return object != nullptr ? object->getChildWithName (type) : ValueTree();
} }
ValueTree ValueTree::getOrCreateChildWithName (const Identifier type, UndoManager* undoManager) ValueTree ValueTree::getOrCreateChildWithName (const Identifier type, UndoManager* undoManager)
{ {
return object != nullptr ? object->getOrCreateChildWithName (type, undoManager) : ValueTree::invalid;
return object != nullptr ? object->getOrCreateChildWithName (type, undoManager) : ValueTree();
} }
ValueTree ValueTree::getChildWithProperty (const Identifier propertyName, const var& propertyValue) const ValueTree ValueTree::getChildWithProperty (const Identifier propertyName, const var& propertyValue) const
{ {
return object != nullptr ? object->getChildWithProperty (propertyName, propertyValue) : ValueTree::invalid;
return object != nullptr ? object->getChildWithProperty (propertyName, propertyValue) : ValueTree();
} }
bool ValueTree::isAChildOf (const ValueTree& possibleParent) const bool ValueTree::isAChildOf (const ValueTree& possibleParent) const
@@ -976,7 +976,7 @@ ValueTree ValueTree::readFromStream (InputStream& input)
const String type (input.readString()); const String type (input.readString());
if (type.isEmpty()) if (type.isEmpty())
return ValueTree::invalid;
return ValueTree();
ValueTree v (type); ValueTree v (type);


+ 1
- 1
modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp View File

@@ -136,7 +136,7 @@ File DirectoryContentsList::getFile (const int index) const
if (const FileInfo* const info = files [index]) if (const FileInfo* const info = files [index])
return root.getChildFile (info->filename); return root.getChildFile (info->filename);
return File::nonexistent;
return File();
} }
bool DirectoryContentsList::contains (const File& targetFile) const bool DirectoryContentsList::contains (const File& targetFile) const


+ 1
- 1
modules/juce_gui_basics/widgets/juce_ListBox.cpp View File

@@ -952,6 +952,6 @@ void ListBoxModel::selectedRowsChanged (int) {}
void ListBoxModel::deleteKeyPressed (int) {} void ListBoxModel::deleteKeyPressed (int) {}
void ListBoxModel::returnKeyPressed (int) {} void ListBoxModel::returnKeyPressed (int) {}
void ListBoxModel::listWasScrolled() {} void ListBoxModel::listWasScrolled() {}
var ListBoxModel::getDragSourceDescription (const SparseSet<int>&) { return var::null; }
var ListBoxModel::getDragSourceDescription (const SparseSet<int>&) { return var(); }
String ListBoxModel::getTooltipForRow (int) { return String::empty; } String ListBoxModel::getTooltipForRow (int) { return String::empty; }
MouseCursor ListBoxModel::getMouseCursorForRow (int) { return MouseCursor::NormalCursor; } MouseCursor ListBoxModel::getMouseCursorForRow (int) { return MouseCursor::NormalCursor; }

+ 1
- 1
modules/juce_gui_basics/widgets/juce_TableListBox.cpp View File

@@ -466,7 +466,7 @@ void TableListBoxModel::returnKeyPressed (int) {}
void TableListBoxModel::listWasScrolled() {} void TableListBoxModel::listWasScrolled() {}
String TableListBoxModel::getCellTooltip (int /*rowNumber*/, int /*columnId*/) { return String::empty; } String TableListBoxModel::getCellTooltip (int /*rowNumber*/, int /*columnId*/) { return String::empty; }
var TableListBoxModel::getDragSourceDescription (const SparseSet<int>&) { return var::null; }
var TableListBoxModel::getDragSourceDescription (const SparseSet<int>&) { return var(); }
Component* TableListBoxModel::refreshComponentForCell (int, int, bool, Component* existingComponentToUpdate) Component* TableListBoxModel::refreshComponentForCell (int, int, bool, Component* existingComponentToUpdate)
{ {


+ 1
- 1
modules/juce_gui_basics/widgets/juce_TreeView.cpp View File

@@ -1371,7 +1371,7 @@ String TreeViewItem::getTooltip()
var TreeViewItem::getDragSourceDescription() var TreeViewItem::getDragSourceDescription()
{ {
return var::null;
return var();
} }
bool TreeViewItem::isInterestedInFileDrag (const StringArray&) bool TreeViewItem::isInterestedInFileDrag (const StringArray&)


Loading…
Cancel
Save