Browse Source

Dragged the singleton macros into the 21st century.. Cleaned up their implementation and gave them new upper-case names to match juce official style. The old names are still defined to avoid breaking old code, but please update before they get deprecated!

tags/2021-05-28
jules 7 years ago
parent
commit
58a99ff139
30 changed files with 211 additions and 214 deletions
  1. +1
    -1
      extras/Projucer/Source/Application/jucer_Main.cpp
  2. +3
    -2
      extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineDLL.h
  3. +1
    -1
      modules/juce_analytics/analytics/juce_Analytics.cpp
  4. +1
    -1
      modules/juce_analytics/analytics/juce_Analytics.h
  5. +2
    -2
      modules/juce_audio_devices/native/juce_win32_Midi.cpp
  6. +2
    -2
      modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp
  7. +160
    -164
      modules/juce_core/memory/juce_Singleton.h
  8. +5
    -5
      modules/juce_events/native/juce_android_Messaging.cpp
  9. +2
    -2
      modules/juce_events/native/juce_linux_Messaging.cpp
  10. +1
    -1
      modules/juce_events/native/juce_win32_WinRTWrapper.cpp
  11. +1
    -1
      modules/juce_events/native/juce_win32_WinRTWrapper.h
  12. +2
    -2
      modules/juce_graphics/fonts/juce_Font.cpp
  13. +2
    -2
      modules/juce_graphics/images/juce_ImageCache.cpp
  14. +2
    -2
      modules/juce_graphics/native/juce_freetype_Fonts.cpp
  15. +1
    -1
      modules/juce_gui_basics/components/juce_ModalComponentManager.cpp
  16. +1
    -1
      modules/juce_gui_basics/components/juce_ModalComponentManager.h
  17. +1
    -1
      modules/juce_gui_basics/filebrowser/juce_ContentSharer.cpp
  18. +1
    -1
      modules/juce_gui_basics/filebrowser/juce_ContentSharer.h
  19. +2
    -2
      modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp
  20. +1
    -1
      modules/juce_gui_basics/native/juce_linux_X11.cpp
  21. +1
    -1
      modules/juce_gui_basics/native/juce_linux_X11.h
  22. +2
    -2
      modules/juce_gui_basics/native/juce_mac_MainMenu.mm
  23. +2
    -2
      modules/juce_gui_basics/native/juce_mac_Windowing.mm
  24. +4
    -4
      modules/juce_gui_basics/native/juce_win32_Windowing.cpp
  25. +2
    -2
      modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp
  26. +3
    -3
      modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp
  27. +1
    -1
      modules/juce_gui_extra/misc/juce_LiveConstantEditor.h
  28. +1
    -1
      modules/juce_gui_extra/misc/juce_PushNotifications.cpp
  29. +1
    -1
      modules/juce_gui_extra/misc/juce_PushNotifications.h
  30. +2
    -2
      modules/juce_video/native/juce_win32_Video.h

+ 1
- 1
extras/Projucer/Source/Application/jucer_Main.cpp View File

@@ -52,7 +52,7 @@
#include "../LiveBuildEngine/UI/jucer_ComponentListComponent.h"
#include "../LiveBuildEngine/jucer_CompileEngineServer.h"
juce_ImplementSingleton (CompileEngineDLL);
JUCE_IMPLEMENT_SINGLETON (CompileEngineDLL)
struct ProjucerAppClasses
{


+ 3
- 2
extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineDLL.h View File

@@ -29,7 +29,7 @@
#include "jucer_LiveCodeBuilderDLL.h"
//==============================================================================
struct CompileEngineDLL : DeletedAtShutdown
struct CompileEngineDLL : private DeletedAtShutdown
{
CompileEngineDLL()
{
@@ -39,6 +39,7 @@ struct CompileEngineDLL : DeletedAtShutdown
~CompileEngineDLL()
{
shutdown();
clearSingletonInstance();
}
bool tryLoadDll()
@@ -117,7 +118,7 @@ struct CompileEngineDLL : DeletedAtShutdown
return userAppData.getChildFile ("Projucer").getChildFile (String ("CompileEngine-") + ProjectInfo::versionString);
}
juce_DeclareSingleton (CompileEngineDLL, false)
JUCE_DECLARE_SINGLETON (CompileEngineDLL, false)
private:
DynamicLibrary dll;


+ 1
- 1
modules/juce_analytics/analytics/juce_Analytics.cpp View File

@@ -62,6 +62,6 @@ void Analytics::setSuspended (bool shouldBeSuspended)
isSuspended = shouldBeSuspended;
}
juce_ImplementSingleton (Analytics)
JUCE_IMPLEMENT_SINGLETON (Analytics)
}

+ 1
- 1
modules/juce_analytics/analytics/juce_Analytics.h View File

@@ -80,7 +80,7 @@ public:
void setSuspended (bool shouldBeSuspended);
#ifndef DOXYGEN
juce_DeclareSingleton (Analytics, false)
JUCE_DECLARE_SINGLETON (Analytics, false)
#endif
private:


+ 2
- 2
modules/juce_audio_devices/native/juce_win32_Midi.cpp View File

@@ -1107,7 +1107,7 @@ public:
MidiServiceType* getService();
juce_DeclareSingleton (MidiService, false)
JUCE_DECLARE_SINGLETON (MidiService, false)
private:
MidiService();
@@ -1115,7 +1115,7 @@ private:
ScopedPointer<MidiServiceType> internal;
};
juce_ImplementSingleton (MidiService)
JUCE_IMPLEMENT_SINGLETON (MidiService)
MidiService::~MidiService()
{


+ 2
- 2
modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp View File

@@ -189,12 +189,12 @@ struct SharedMessageThread : public Thread
{}
}
juce_DeclareSingleton (SharedMessageThread, false)
JUCE_DECLARE_SINGLETON (SharedMessageThread, false)
bool initialised = false;
};
juce_ImplementSingleton (SharedMessageThread)
JUCE_IMPLEMENT_SINGLETON (SharedMessageThread)
#endif


+ 160
- 164
modules/juce_core/memory/juce_Singleton.h View File

@@ -25,12 +25,115 @@ namespace juce
//==============================================================================
/**
Macro to declare member variables and methods for a singleton class.
Used by the JUCE_DECLARE_SINGLETON macros to manage a static pointer
to a singleton instance.
You generally won't use this directly, but see the macros JUCE_DECLARE_SINGLETON,
JUCE_DECLARE_SINGLETON_SINGLETHREADED, JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL,
and JUCE_IMPLEMENT_SINGLETON for how it is intended to be used.
*/
template <typename Type, typename MutexType, bool onlyCreateOncePerRun>
struct SingletonHolder : private MutexType // (inherited so we can use the empty-base-class optimisation)
{
SingletonHolder() noexcept {}
~SingletonHolder()
{
/* The static singleton holder is being deleted before the object that it holds
has been deleted. This could mean that you've forgotten to call clearSingletonInstance()
in the class's destructor, or have failed to delete it before your app shuts down.
If you're having trouble cleaning up your singletons, perhaps consider using the
SharedResourcePointer class instead.
*/
jassert (instance == nullptr);
}
/** Returns the current instance, or creates a new instance if there isn't one. */
Type* get()
{
if (instance == nullptr)
{
typename MutexType::ScopedLockType sl (*this);
if (instance == nullptr)
{
if (onlyCreateOncePerRun)
{
static bool createdOnceAlready = false;
if (createdOnceAlready)
{
// This means that the doNotRecreateAfterDeletion flag was set
// and you tried to create the singleton more than once.
jassertfalse;
return nullptr;
}
createdOnceAlready = true;
}
static bool alreadyInside = false;
if (alreadyInside)
{
// This means that your object's constructor has done something which has
// ended up causing a recursive loop of singleton creation..
jassertfalse;
}
else
{
alreadyInside = true;
getWithoutChecking();
alreadyInside = false;
}
}
}
return instance;
}
/** Returns the current instance, or creates a new instance if there isn't one, but doesn't do
any locking, or checking for recursion or error conditions.
*/
Type* getWithoutChecking()
{
if (instance == nullptr)
{
auto newObject = new Type(); // (create into a local so that instance is still null during construction)
instance = newObject;
}
return instance;
}
/** Deletes and resets the current instance, if there is one. */
void deleteInstance()
{
typename MutexType::ScopedLockType sl (*this);
auto old = instance;
instance = nullptr;
delete old;
}
/** Called by the class's destructor to clear the pointer if it is currently set to the given object. */
void clear (Type* expectedObject) noexcept
{
if (instance == expectedObject)
instance = nullptr;
}
To use this, add the line juce_DeclareSingleton (MyClass, doNotRecreateAfterDeletion)
Type* instance = nullptr;
};
//==============================================================================
/**
Macro to generate the appropriate methods and boilerplate for a singleton class.
To use this, add the line JUCE_DECLARE_SINGLETON(MyClass, doNotRecreateAfterDeletion)
to the class's definition.
Then put a macro juce_ImplementSingleton (MyClass) along with the class's
Then put a macro JUCE_IMPLEMENT_SINGLETON(MyClass) along with the class's
implementation code.
It's also a very good idea to also add the call clearSingletonInstance() in your class's
@@ -42,12 +145,9 @@ namespace juce
e.g. @code
class MySingleton
struct MySingleton
{
public:
MySingleton()
{
}
MySingleton() {}
~MySingleton()
{
@@ -56,14 +156,15 @@ namespace juce
clearSingletonInstance();
}
juce_DeclareSingleton (MySingleton, false)
JUCE_DECLARE_SINGLETON (MySingleton, false)
};
juce_ImplementSingleton (MySingleton)
// ..and this goes in a suitable .cpp file:
JUCE_IMPLEMENT_SINGLETON (MySingleton)
// example of usage:
MySingleton* m = MySingleton::getInstance(); // creates the singleton if there isn't already one.
auto* m = MySingleton::getInstance(); // creates the singleton if there isn't already one.
...
@@ -77,84 +178,38 @@ namespace juce
objects being accidentally re-created during your app's shutdown code.
If you know that your object will only be created and deleted by a single thread, you
can use the slightly more efficient juce_DeclareSingleton_SingleThreaded() macro instead
can use the slightly more efficient JUCE_DECLARE_SINGLETON_SINGLETHREADED macro instead
of this one.
@see juce_ImplementSingleton, juce_DeclareSingleton_SingleThreaded
@see JUCE_IMPLEMENT_SINGLETON, JUCE_DECLARE_SINGLETON_SINGLETHREADED
*/
#define juce_DeclareSingleton(classname, doNotRecreateAfterDeletion) \
\
static classname* _singletonInstance; \
static juce::CriticalSection _singletonLock; \
\
static classname* JUCE_CALLTYPE getInstance() \
{ \
if (_singletonInstance == nullptr) \
{\
const juce::ScopedLock sl (_singletonLock); \
\
if (_singletonInstance == nullptr) \
{ \
static bool alreadyInside = false; \
static bool createdOnceAlready = false; \
\
const bool problem = alreadyInside || ((doNotRecreateAfterDeletion) && createdOnceAlready); \
jassert (! problem); \
if (! problem) \
{ \
createdOnceAlready = true; \
alreadyInside = true; \
classname* newObject = new classname(); /* (use a stack variable to avoid setting the newObject value before the class has finished its constructor) */ \
alreadyInside = false; \
\
_singletonInstance = newObject; \
} \
} \
} \
\
return _singletonInstance; \
} \
#define JUCE_DECLARE_SINGLETON(Classname, doNotRecreateAfterDeletion) \
\
static inline classname* JUCE_CALLTYPE getInstanceWithoutCreating() noexcept\
{ \
return _singletonInstance; \
} \
static juce::SingletonHolder<Classname, juce::CriticalSection, doNotRecreateAfterDeletion> singletonHolder; \
friend decltype (singletonHolder); \
\
static void JUCE_CALLTYPE deleteInstance() \
{ \
const juce::ScopedLock sl (_singletonLock); \
if (_singletonInstance != nullptr) \
{ \
classname* const old = _singletonInstance; \
_singletonInstance = nullptr; \
delete old; \
} \
} \
\
void clearSingletonInstance() noexcept\
{ \
if (_singletonInstance == this) \
_singletonInstance = nullptr; \
}
static Classname* JUCE_CALLTYPE getInstance() { return singletonHolder.get(); } \
static Classname* JUCE_CALLTYPE getInstanceWithoutCreating() noexcept { return singletonHolder.instance; } \
static void JUCE_CALLTYPE deleteInstance() noexcept { singletonHolder.deleteInstance(); } \
void clearSingletonInstance() noexcept { singletonHolder.clear (this); }
//==============================================================================
/** This is a counterpart to the juce_DeclareSingleton macro.
/** This is a counterpart to the JUCE_DECLARE_SINGLETON macros.
After adding the juce_DeclareSingleton to the class definition, this macro has
After adding the JUCE_DECLARE_SINGLETON to the class definition, this macro has
to be used in the cpp file.
*/
#define juce_ImplementSingleton(classname) \
#define JUCE_IMPLEMENT_SINGLETON(Classname) \
\
classname* classname::_singletonInstance = nullptr; \
juce::CriticalSection classname::_singletonLock;
decltype (Classname::singletonHolder) Classname::singletonHolder;
//==============================================================================
/**
Macro to declare member variables and methods for a singleton class.
This is exactly the same as juce_DeclareSingleton, but doesn't use a critical
This is exactly the same as JUCE_DECLARE_SINGLETON, but doesn't use a critical
section to make access to it thread-safe. If you know that your object will
only ever be created or deleted by a single thread, then this is a
more efficient version to use.
@@ -164,120 +219,61 @@ namespace juce
object, getInstance() will refuse to create another one. This can be useful to stop
objects being accidentally re-created during your app's shutdown code.
See the documentation for juce_DeclareSingleton for more information about
how to use it, the only difference being that you have to use
juce_ImplementSingleton_SingleThreaded instead of juce_ImplementSingleton.
See the documentation for JUCE_DECLARE_SINGLETON for more information about
how to use it. Just like JUCE_DECLARE_SINGLETON you need to also have a
corresponding JUCE_IMPLEMENT_SINGLETON statement somewhere in your code.
@see juce_ImplementSingleton_SingleThreaded, juce_DeclareSingleton, juce_DeclareSingleton_SingleThreaded_Minimal
@see JUCE_IMPLEMENT_SINGLETON, JUCE_DECLARE_SINGLETON, JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL
*/
#define juce_DeclareSingleton_SingleThreaded(classname, doNotRecreateAfterDeletion) \
\
static classname* _singletonInstance; \
\
static classname* getInstance() \
{ \
if (_singletonInstance == nullptr) \
{ \
static bool alreadyInside = false; \
static bool createdOnceAlready = false; \
\
const bool problem = alreadyInside || ((doNotRecreateAfterDeletion) && createdOnceAlready); \
jassert (! problem); \
if (! problem) \
{ \
createdOnceAlready = true; \
alreadyInside = true; \
classname* newObject = new classname(); /* (use a stack variable to avoid setting the newObject value before the class has finished its constructor) */ \
alreadyInside = false; \
#define JUCE_DECLARE_SINGLETON_SINGLETHREADED(Classname, doNotRecreateAfterDeletion) \
\
_singletonInstance = newObject; \
} \
} \
static juce::SingletonHolder<Classname, juce::DummyCriticalSection, doNotRecreateAfterDeletion> singletonHolder; \
friend decltype (singletonHolder); \
\
return _singletonInstance; \
} \
\
static inline classname* getInstanceWithoutCreating() noexcept\
{ \
return _singletonInstance; \
} \
\
static void deleteInstance() \
{ \
if (_singletonInstance != nullptr) \
{ \
classname* const old = _singletonInstance; \
_singletonInstance = nullptr; \
delete old; \
} \
} \
\
void clearSingletonInstance() noexcept\
{ \
if (_singletonInstance == this) \
_singletonInstance = nullptr; \
}
static Classname* JUCE_CALLTYPE getInstance() { return singletonHolder.get(); } \
static Classname* JUCE_CALLTYPE getInstanceWithoutCreating() noexcept { return singletonHolder.instance; } \
static void JUCE_CALLTYPE deleteInstance() noexcept { singletonHolder.deleteInstance(); } \
void clearSingletonInstance() noexcept { singletonHolder.clear (this); }
//==============================================================================
/**
Macro to declare member variables and methods for a singleton class.
This is like juce_DeclareSingleton_SingleThreaded, but doesn't do any checking
This is like JUCE_DECLARE_SINGLETON_SINGLETHREADED, but doesn't do any checking
for recursion or repeated instantiation. It's intended for use as a lightweight
version of a singleton, where you're using it in very straightforward
circumstances and don't need the extra checking.
Just use the normal juce_ImplementSingleton_SingleThreaded as the counterpart
to this declaration, as you would with juce_DeclareSingleton_SingleThreaded.
Just use the normal JUCE_IMPLEMENT_SINGLETON_SINGLETHREADED as the counterpart
to this declaration, as you would with JUCE_DECLARE_SINGLETON_SINGLETHREADED.
See the documentation for juce_DeclareSingleton for more information about
See the documentation for JUCE_DECLARE_SINGLETON for more information about
how to use it, the only difference being that you have to use
juce_ImplementSingleton_SingleThreaded instead of juce_ImplementSingleton.
JUCE_IMPLEMENT_SINGLETON_SINGLETHREADED instead of JUCE_IMPLEMENT_SINGLETON.
@see juce_ImplementSingleton_SingleThreaded, juce_DeclareSingleton
@see JUCE_IMPLEMENT_SINGLETON_SINGLETHREADED, JUCE_DECLARE_SINGLETON
*/
#define juce_DeclareSingleton_SingleThreaded_Minimal(classname) \
\
static classname* _singletonInstance; \
\
static classname* getInstance() \
{ \
if (_singletonInstance == nullptr) \
_singletonInstance = new classname(); \
#define JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL(Classname) \
\
return _singletonInstance; \
} \
static juce::SingletonHolder<Classname, juce::DummyCriticalSection, false> singletonHolder; \
friend decltype (singletonHolder); \
\
static inline classname* getInstanceWithoutCreating() noexcept\
{ \
return _singletonInstance; \
} \
\
static void deleteInstance() \
{ \
if (_singletonInstance != nullptr) \
{ \
classname* const old = _singletonInstance; \
_singletonInstance = nullptr; \
delete old; \
} \
} \
\
void clearSingletonInstance() noexcept\
{ \
if (_singletonInstance == this) \
_singletonInstance = nullptr; \
}
static Classname* JUCE_CALLTYPE getInstance() { return singletonHolder.getWithoutChecking(); } \
static Classname* JUCE_CALLTYPE getInstanceWithoutCreating() noexcept { return singletonHolder.instance; } \
static void JUCE_CALLTYPE deleteInstance() noexcept { singletonHolder.deleteInstance(); } \
void clearSingletonInstance() noexcept { singletonHolder.clear (this); }
//==============================================================================
/** This is a counterpart to the juce_DeclareSingleton_SingleThreaded macro.
After adding juce_DeclareSingleton_SingleThreaded or juce_DeclareSingleton_SingleThreaded_Minimal
to the class definition, this macro has to be used somewhere in the cpp file.
*/
#define juce_ImplementSingleton_SingleThreaded(classname) \
\
classname* classname::_singletonInstance = nullptr;
#ifndef DOXYGEN
// These are ancient macros, and have now been updated with new names to match the JUCE style guide,
// so please update your code to use the newer versions!
#define juce_DeclareSingleton(Classname, doNotRecreate) JUCE_DECLARE_SINGLETON(Classname, doNotRecreate)
#define juce_DeclareSingleton_SingleThreaded(Classname, doNotRecreate) JUCE_DECLARE_SINGLETON_SINGLETHREADED(Classname, doNotRecreate)
#define juce_DeclareSingleton_SingleThreaded_Minimal(Classname) JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL(Classname)
#define juce_ImplementSingleton(Classname) JUCE_IMPLEMENT_SINGLETON(Classname)
#define juce_ImplementSingleton_SingleThreaded(Classname) JUCE_IMPLEMENT_SINGLETON(Classname)
#endif
} // namespace juce

+ 5
- 5
modules/juce_events/native/juce_android_Messaging.cpp View File

@@ -34,7 +34,7 @@ DECLARE_JNI_CLASS (JNIHandler, "android/os/Handler");
//==============================================================================
namespace Android
{
class Runnable : public juce::AndroidInterfaceImplementer
class Runnable : public juce::AndroidInterfaceImplementer
{
public:
virtual void run() = 0;
@@ -58,7 +58,7 @@ namespace Android
struct Handler
{
juce_DeclareSingleton (Handler, false)
JUCE_DECLARE_SINGLETON (Handler, false)
Handler() : nativeHandler (getEnv()->NewObject (JNIHandler, JNIHandler.constructor)) {}
@@ -70,13 +70,13 @@ namespace Android
GlobalRef nativeHandler;
};
juce_ImplementSingleton (Handler);
JUCE_IMPLEMENT_SINGLETON (Handler)
}
//==============================================================================
struct AndroidMessageQueue : private Android::Runnable
{
juce_DeclareSingleton_SingleThreaded (AndroidMessageQueue, true)
JUCE_DECLARE_SINGLETON_SINGLETHREADED (AndroidMessageQueue, true)
AndroidMessageQueue()
: self (CreateJavaInterface (this, "java/lang/Runnable").get())
@@ -118,7 +118,7 @@ private:
Android::Handler handler;
};
juce_ImplementSingleton_SingleThreaded (AndroidMessageQueue);
JUCE_IMPLEMENT_SINGLETON (AndroidMessageQueue)
//==============================================================================
void MessageManager::doPlatformSpecificInitialisation() { AndroidMessageQueue::getInstance(); }


+ 2
- 2
modules/juce_events/native/juce_linux_Messaging.cpp View File

@@ -132,7 +132,7 @@ public:
}
//==============================================================================
juce_DeclareSingleton_SingleThreaded_Minimal (InternalMessageQueue)
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (InternalMessageQueue)
private:
CriticalSection lock;
@@ -165,7 +165,7 @@ private:
}
};
juce_ImplementSingleton_SingleThreaded (InternalMessageQueue)
JUCE_IMPLEMENT_SINGLETON (InternalMessageQueue)
//==============================================================================


+ 1
- 1
modules/juce_events/native/juce_win32_WinRTWrapper.cpp View File

@@ -22,5 +22,5 @@
namespace juce
{
juce_ImplementSingleton (WinRTWrapper)
JUCE_IMPLEMENT_SINGLETON (WinRTWrapper)
}

+ 1
- 1
modules/juce_events/native/juce_win32_WinRTWrapper.h View File

@@ -26,7 +26,7 @@ namespace juce
class WinRTWrapper : public DeletedAtShutdown
{
public:
juce_DeclareSingleton (WinRTWrapper, true)
JUCE_DECLARE_SINGLETON (WinRTWrapper, true)
class ScopedHString
{


+ 2
- 2
modules/juce_graphics/fonts/juce_Font.cpp View File

@@ -60,7 +60,7 @@ public:
clearSingletonInstance();
}
juce_DeclareSingleton (TypefaceCache, false)
JUCE_DECLARE_SINGLETON (TypefaceCache, false)
void setSize (const int numToCache)
{
@@ -157,7 +157,7 @@ private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TypefaceCache)
};
juce_ImplementSingleton (TypefaceCache)
JUCE_IMPLEMENT_SINGLETON (TypefaceCache)
void Typeface::setTypefaceCacheSize (int numFontsToCache)
{


+ 2
- 2
modules/juce_graphics/images/juce_ImageCache.cpp View File

@@ -33,7 +33,7 @@ struct ImageCache::Pimpl : private Timer,
Pimpl() {}
~Pimpl() { clearSingletonInstance(); }
juce_DeclareSingleton_SingleThreaded_Minimal (ImageCache::Pimpl)
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (ImageCache::Pimpl)
Image getFromHashCode (const int64 hashCode) noexcept
{
@@ -111,7 +111,7 @@ struct ImageCache::Pimpl : private Timer,
JUCE_DECLARE_NON_COPYABLE (Pimpl)
};
juce_ImplementSingleton_SingleThreaded (ImageCache::Pimpl)
JUCE_IMPLEMENT_SINGLETON (ImageCache::Pimpl)
//==============================================================================


+ 2
- 2
modules/juce_graphics/native/juce_freetype_Fonts.cpp View File

@@ -229,7 +229,7 @@ public:
sansSerif.addIfNotAlreadyThere (faces.getUnchecked(i)->family);
}
juce_DeclareSingleton_SingleThreaded_Minimal (FTTypefaceList)
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (FTTypefaceList)
private:
FTLibWrapper::Ptr library;
@@ -288,7 +288,7 @@ private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FTTypefaceList)
};
juce_ImplementSingleton_SingleThreaded (FTTypefaceList)
JUCE_IMPLEMENT_SINGLETON (FTTypefaceList)
//==============================================================================


+ 1
- 1
modules/juce_gui_basics/components/juce_ModalComponentManager.cpp View File

@@ -90,7 +90,7 @@ ModalComponentManager::~ModalComponentManager()
clearSingletonInstance();
}
juce_ImplementSingleton_SingleThreaded (ModalComponentManager)
JUCE_IMPLEMENT_SINGLETON (ModalComponentManager)
//==============================================================================


+ 1
- 1
modules/juce_gui_basics/components/juce_ModalComponentManager.h View File

@@ -75,7 +75,7 @@ public:
//==============================================================================
#ifndef DOXYGEN
juce_DeclareSingleton_SingleThreaded_Minimal (ModalComponentManager)
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (ModalComponentManager)
#endif
//==============================================================================


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

@@ -148,7 +148,7 @@ private:
#endif
//==============================================================================
juce_ImplementSingleton (ContentSharer)
JUCE_IMPLEMENT_SINGLETON (ContentSharer)
ContentSharer::ContentSharer() {}
ContentSharer::~ContentSharer() { clearSingletonInstance(); }


+ 1
- 1
modules/juce_gui_basics/filebrowser/juce_ContentSharer.h View File

@@ -36,7 +36,7 @@ namespace juce
class JUCE_API ContentSharer
{
public:
juce_DeclareSingleton (ContentSharer, false)
JUCE_DECLARE_SINGLETON (ContentSharer, false)
/** Shares the given files. Each URL should be either a full file path
or it should point to a resource within the application bundle. For


+ 2
- 2
modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp View File

@@ -78,10 +78,10 @@ struct ReportingThreadContainer : public ChangeListener,
ScopedPointer<ReportingThread> reportingThread;
juce_DeclareSingleton_SingleThreaded_Minimal (ReportingThreadContainer)
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (ReportingThreadContainer)
};
juce_ImplementSingleton_SingleThreaded (ReportingThreadContainer)
JUCE_IMPLEMENT_SINGLETON (ReportingThreadContainer)
//==============================================================================
struct ReportingThread : public Thread,


+ 1
- 1
modules/juce_gui_basics/native/juce_linux_X11.cpp View File

@@ -232,7 +232,7 @@ void XWindowSystem::destroyXDisplay() noexcept
LinuxEventLoop::removeWindowSystemFd();
}
juce_ImplementSingleton (XWindowSystem)
JUCE_IMPLEMENT_SINGLETON (XWindowSystem)
//==============================================================================
ScopedXDisplay::ScopedXDisplay() : display (XWindowSystem::getInstance()->displayRef())


+ 1
- 1
modules/juce_gui_basics/native/juce_linux_X11.h View File

@@ -42,7 +42,7 @@ public:
XDisplay displayRef() noexcept;
XDisplay displayUnref() noexcept;
juce_DeclareSingleton (XWindowSystem, false)
JUCE_DECLARE_SINGLETON (XWindowSystem, false)
private:
XDisplay display = {};


+ 2
- 2
modules/juce_gui_basics/native/juce_mac_MainMenu.mm View File

@@ -56,10 +56,10 @@ struct JuceMainMenuBarHolder : private DeletedAtShutdown
NSMenu* mainMenuBar = nil;
juce_DeclareSingleton_SingleThreaded (JuceMainMenuBarHolder, true)
JUCE_DECLARE_SINGLETON_SINGLETHREADED (JuceMainMenuBarHolder, true)
};
juce_ImplementSingleton_SingleThreaded (JuceMainMenuBarHolder)
JUCE_IMPLEMENT_SINGLETON (JuceMainMenuBarHolder)
//==============================================================================
class JuceMainMenuHandler : private MenuBarModel::Listener,


+ 2
- 2
modules/juce_gui_basics/native/juce_mac_Windowing.mm View File

@@ -442,12 +442,12 @@ struct DisplaySettingsChangeCallback : private DeletedAtShutdown
const_cast<Desktop::Displays&> (Desktop::getInstance().getDisplays()).refresh();
}
juce_DeclareSingleton_SingleThreaded_Minimal (DisplaySettingsChangeCallback)
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (DisplaySettingsChangeCallback)
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DisplaySettingsChangeCallback)
};
juce_ImplementSingleton_SingleThreaded (DisplaySettingsChangeCallback)
JUCE_IMPLEMENT_SINGLETON (DisplaySettingsChangeCallback)
static Rectangle<int> convertDisplayRect (NSRect r, CGFloat mainScreenBottom)
{


+ 4
- 4
modules/juce_gui_basics/native/juce_win32_Windowing.cpp View File

@@ -755,7 +755,7 @@ struct OnScreenKeyboard : public DeletedAtShutdown,
startTimer (10);
}
juce_DeclareSingleton_SingleThreaded (OnScreenKeyboard, true)
JUCE_DECLARE_SINGLETON_SINGLETHREADED (OnScreenKeyboard, true)
private:
OnScreenKeyboard()
@@ -803,7 +803,7 @@ private:
ComSmartPtr<ITipInvocation> tipInvocation;
};
juce_ImplementSingleton_SingleThreaded (OnScreenKeyboard)
JUCE_IMPLEMENT_SINGLETON (OnScreenKeyboard)
//==============================================================================
struct HSTRING_PRIVATE;
@@ -1606,7 +1606,7 @@ private:
LPCTSTR getWindowClassName() const noexcept { return (LPCTSTR) (pointer_sized_uint) atom; }
juce_DeclareSingleton_SingleThreaded_Minimal (WindowClassHolder)
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (WindowClassHolder)
private:
ATOM atom;
@@ -3589,7 +3589,7 @@ JUCE_API ComponentPeer* createNonRepaintingEmbeddedWindowsPeer (Component& compo
}
juce_ImplementSingleton_SingleThreaded (HWNDComponentPeer::WindowClassHolder)
JUCE_IMPLEMENT_SINGLETON (HWNDComponentPeer::WindowClassHolder)
//==============================================================================


+ 2
- 2
modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp View File

@@ -35,7 +35,7 @@ public:
TopLevelWindowManager() {}
~TopLevelWindowManager() { clearSingletonInstance(); }
juce_DeclareSingleton_SingleThreaded_Minimal (TopLevelWindowManager)
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (TopLevelWindowManager)
void checkFocusAsync()
{
@@ -122,7 +122,7 @@ private:
JUCE_DECLARE_NON_COPYABLE (TopLevelWindowManager)
};
juce_ImplementSingleton_SingleThreaded (TopLevelWindowManager)
JUCE_IMPLEMENT_SINGLETON (TopLevelWindowManager)
void juce_checkCurrentlyFocusedTopLevelWindow();
void juce_checkCurrentlyFocusedTopLevelWindow()


+ 3
- 3
modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp View File

@@ -40,7 +40,7 @@ public:
AllComponentRepainter() {}
~AllComponentRepainter() { clearSingletonInstance(); }
juce_DeclareSingleton (AllComponentRepainter, false)
JUCE_DECLARE_SINGLETON (AllComponentRepainter, false)
void trigger()
{
@@ -89,8 +89,8 @@ private:
}
};
juce_ImplementSingleton (AllComponentRepainter)
juce_ImplementSingleton (ValueList)
JUCE_IMPLEMENT_SINGLETON (AllComponentRepainter)
JUCE_IMPLEMENT_SINGLETON (ValueList)
//==============================================================================
int64 parseInt (String s)


+ 1
- 1
modules/juce_gui_extra/misc/juce_LiveConstantEditor.h View File

@@ -200,7 +200,7 @@ namespace LiveConstantEditor
ValueList();
~ValueList();
juce_DeclareSingleton (ValueList, false)
JUCE_DECLARE_SINGLETON (ValueList, false)
template <typename Type>
LiveValue<Type>& getValue (const char* file, int line, const Type& initialValue)


+ 1
- 1
modules/juce_gui_extra/misc/juce_PushNotifications.cpp View File

@@ -33,7 +33,7 @@ bool PushNotifications::Notification::isValid() const noexcept { return true; }
#endif
//==============================================================================
juce_ImplementSingleton (PushNotifications)
JUCE_IMPLEMENT_SINGLETON (PushNotifications)
PushNotifications::PushNotifications()
#if JUCE_PUSH_NOTIFICATIONS


+ 1
- 1
modules/juce_gui_extra/misc/juce_PushNotifications.h View File

@@ -45,7 +45,7 @@ class JUCE_API PushNotifications
{
public:
#ifndef DOXYGEN
juce_DeclareSingleton (PushNotifications, false)
JUCE_DECLARE_SINGLETON (PushNotifications, false)
#endif
//==========================================================================


+ 2
- 2
modules/juce_video/native/juce_win32_Video.h View File

@@ -772,7 +772,7 @@ private:
bool isRegistered() const noexcept { return atom != 0; }
LPCTSTR getWindowClassName() const noexcept { return (LPCTSTR) (pointer_sized_uint) MAKELONG (atom, 0); }
juce_DeclareSingleton_SingleThreaded_Minimal (NativeWindowClass)
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (NativeWindowClass)
private:
NativeWindowClass()
@@ -889,4 +889,4 @@ private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl)
};
juce_ImplementSingleton_SingleThreaded (VideoComponent::Pimpl::DirectShowContext::NativeWindowClass)
JUCE_IMPLEMENT_SINGLETON (VideoComponent::Pimpl::DirectShowContext::NativeWindowClass)

Loading…
Cancel
Save