mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-18 00:54:19 +00:00
This commit is contained in:
parent
7182195672
commit
e4304ef483
5 changed files with 58 additions and 54 deletions
|
|
@ -68,12 +68,12 @@ JUCEApplication::~JUCEApplication()
|
|||
{
|
||||
}
|
||||
|
||||
JUCEApplication* JUCEApplication::getInstance()
|
||||
JUCEApplication* JUCEApplication::getInstance() throw()
|
||||
{
|
||||
return appInstance;
|
||||
}
|
||||
|
||||
bool JUCEApplication::isInitialising() const
|
||||
bool JUCEApplication::isInitialising() const throw()
|
||||
{
|
||||
return stillInitialising;
|
||||
}
|
||||
|
|
@ -155,20 +155,6 @@ bool JUCEApplication::perform (const InvocationInfo& info)
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
// used as a listener object later on..
|
||||
class NewAppListener : public ActionListener
|
||||
{
|
||||
public:
|
||||
void actionListenerCallback (const String& message)
|
||||
{
|
||||
if (message.startsWith (appInstance->getApplicationName() + T("/")))
|
||||
{
|
||||
appInstance->anotherInstanceStarted (message.fromFirstOccurrenceOf (T("/"),
|
||||
false, false));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int JUCEApplication::main (String& commandLine, JUCEApplication* const app)
|
||||
{
|
||||
jassert (appInstance == 0);
|
||||
|
|
@ -185,8 +171,7 @@ int JUCEApplication::main (String& commandLine, JUCEApplication* const app)
|
|||
|
||||
if (! appLock->enter(0))
|
||||
{
|
||||
MessageManager::broadcastMessage (app->getApplicationName()
|
||||
+ T("/") + commandLine);
|
||||
MessageManager::broadcastMessage (app->getApplicationName() + "/" + commandLine);
|
||||
|
||||
delete appInstance;
|
||||
appInstance = 0;
|
||||
|
|
@ -207,16 +192,14 @@ int JUCEApplication::main (String& commandLine, JUCEApplication* const app)
|
|||
commandLine = String::empty;
|
||||
|
||||
// register for broadcast new app messages
|
||||
NewAppListener* const newAppListener = new NewAppListener();
|
||||
|
||||
MessageManager::getInstance()->registerBroadcastListener (newAppListener);
|
||||
MessageManager::getInstance()->registerBroadcastListener (app);
|
||||
|
||||
app->stillInitialising = false;
|
||||
|
||||
// now loop until a quit message is received..
|
||||
useForce = MessageManager::getInstance()->runDispatchLoop();
|
||||
|
||||
delete newAppListener;
|
||||
MessageManager::getInstance()->deregisterBroadcastListener (app);
|
||||
|
||||
if (appLock != 0)
|
||||
{
|
||||
|
|
@ -297,6 +280,13 @@ int JUCEApplication::main (int argc, char* argv[],
|
|||
return JUCEApplication::main (cmd, newApp);
|
||||
}
|
||||
|
||||
void JUCEApplication::actionListenerCallback (const String& message)
|
||||
{
|
||||
if (message.startsWith (getApplicationName() + "/"))
|
||||
{
|
||||
anotherInstanceStarted (message.fromFirstOccurrenceOf (T("/"), false, false));
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static bool juceInitialisedGUI = false;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#define __JUCE_APPLICATION_JUCEHEADER__
|
||||
|
||||
#include "juce_ApplicationCommandTarget.h"
|
||||
#include "../events/juce_ActionListener.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -103,7 +104,8 @@
|
|||
|
||||
@see MessageManager, DeletedAtShutdown
|
||||
*/
|
||||
class JUCE_API JUCEApplication : public ApplicationCommandTarget
|
||||
class JUCE_API JUCEApplication : public ApplicationCommandTarget,
|
||||
private ActionListener
|
||||
{
|
||||
protected:
|
||||
//==============================================================================
|
||||
|
|
@ -126,7 +128,7 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Returns the global instance of the application object being run. */
|
||||
static JUCEApplication* getInstance();
|
||||
static JUCEApplication* getInstance() throw();
|
||||
|
||||
//==============================================================================
|
||||
/** Called when the application starts.
|
||||
|
|
@ -154,7 +156,7 @@ public:
|
|||
This is handy for things like splash screens to know when the app's up-and-running
|
||||
properly.
|
||||
*/
|
||||
bool isInitialising() const;
|
||||
bool isInitialising() const throw();
|
||||
|
||||
/* Called to allow the application to clear up before exiting.
|
||||
|
||||
|
|
@ -269,6 +271,8 @@ public:
|
|||
void getAllCommands (Array <CommandID>& commands);
|
||||
/** @internal */
|
||||
bool perform (const InvocationInfo& info);
|
||||
/** @internal */
|
||||
void actionListenerCallback (const String& message);
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ BEGIN_JUCE_NAMESPACE
|
|||
|
||||
|
||||
//==============================================================================
|
||||
KeyPressMappingSet::KeyPressMappingSet (ApplicationCommandManager* const commandManager_)
|
||||
KeyPressMappingSet::KeyPressMappingSet (ApplicationCommandManager* const commandManager_) throw()
|
||||
: commandManager (commandManager_)
|
||||
{
|
||||
// A manager is needed to get the descriptions of commands, and will be called when
|
||||
|
|
@ -49,7 +49,7 @@ KeyPressMappingSet::KeyPressMappingSet (ApplicationCommandManager* const command
|
|||
Desktop::getInstance().addFocusChangeListener (this);
|
||||
}
|
||||
|
||||
KeyPressMappingSet::KeyPressMappingSet (const KeyPressMappingSet& other)
|
||||
KeyPressMappingSet::KeyPressMappingSet (const KeyPressMappingSet& other) throw()
|
||||
: commandManager (other.commandManager)
|
||||
{
|
||||
Desktop::getInstance().addFocusChangeListener (this);
|
||||
|
|
@ -72,7 +72,7 @@ const Array <KeyPress> KeyPressMappingSet::getKeyPressesAssignedToCommand (const
|
|||
|
||||
void KeyPressMappingSet::addKeyPress (const CommandID commandID,
|
||||
const KeyPress& newKeyPress,
|
||||
int insertIndex)
|
||||
int insertIndex) throw()
|
||||
{
|
||||
if (findCommandForKeyPress (newKeyPress) != commandID)
|
||||
{
|
||||
|
|
@ -107,7 +107,7 @@ void KeyPressMappingSet::addKeyPress (const CommandID commandID,
|
|||
}
|
||||
}
|
||||
|
||||
void KeyPressMappingSet::resetToDefaultMappings()
|
||||
void KeyPressMappingSet::resetToDefaultMappings() throw()
|
||||
{
|
||||
mappings.clear();
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ void KeyPressMappingSet::resetToDefaultMappings()
|
|||
sendChangeMessage (this);
|
||||
}
|
||||
|
||||
void KeyPressMappingSet::resetToDefaultMapping (const CommandID commandID)
|
||||
void KeyPressMappingSet::resetToDefaultMapping (const CommandID commandID) throw()
|
||||
{
|
||||
clearAllKeyPresses (commandID);
|
||||
|
||||
|
|
@ -138,15 +138,16 @@ void KeyPressMappingSet::resetToDefaultMapping (const CommandID commandID)
|
|||
}
|
||||
}
|
||||
|
||||
void KeyPressMappingSet::clearAllKeyPresses()
|
||||
void KeyPressMappingSet::clearAllKeyPresses() throw()
|
||||
{
|
||||
if (mappings.size() > 0)
|
||||
{
|
||||
sendChangeMessage (this);
|
||||
|
||||
mappings.clear();
|
||||
mappings.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void KeyPressMappingSet::clearAllKeyPresses (const CommandID commandID)
|
||||
void KeyPressMappingSet::clearAllKeyPresses (const CommandID commandID) throw()
|
||||
{
|
||||
for (int i = mappings.size(); --i >= 0;)
|
||||
{
|
||||
|
|
@ -158,7 +159,7 @@ void KeyPressMappingSet::clearAllKeyPresses (const CommandID commandID)
|
|||
}
|
||||
}
|
||||
|
||||
void KeyPressMappingSet::removeKeyPress (const KeyPress& keypress)
|
||||
void KeyPressMappingSet::removeKeyPress (const KeyPress& keypress) throw()
|
||||
{
|
||||
if (keypress.isValid())
|
||||
{
|
||||
|
|
@ -179,7 +180,7 @@ void KeyPressMappingSet::removeKeyPress (const KeyPress& keypress)
|
|||
}
|
||||
|
||||
void KeyPressMappingSet::removeKeyPress (const CommandID commandID,
|
||||
const int keyPressIndex)
|
||||
const int keyPressIndex) throw()
|
||||
{
|
||||
for (int i = mappings.size(); --i >= 0;)
|
||||
{
|
||||
|
|
@ -193,7 +194,7 @@ void KeyPressMappingSet::removeKeyPress (const CommandID commandID,
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
CommandID KeyPressMappingSet::findCommandForKeyPress (const KeyPress& keyPress) const
|
||||
CommandID KeyPressMappingSet::findCommandForKeyPress (const KeyPress& keyPress) const throw()
|
||||
{
|
||||
for (int i = 0; i < mappings.size(); ++i)
|
||||
if (mappings.getUnchecked(i)->keypresses.contains (keyPress))
|
||||
|
|
@ -203,7 +204,7 @@ CommandID KeyPressMappingSet::findCommandForKeyPress (const KeyPress& keyPress)
|
|||
}
|
||||
|
||||
bool KeyPressMappingSet::containsMapping (const CommandID commandID,
|
||||
const KeyPress& keyPress) const
|
||||
const KeyPress& keyPress) const throw()
|
||||
{
|
||||
for (int i = mappings.size(); --i >= 0;)
|
||||
if (mappings.getUnchecked(i)->commandID == commandID)
|
||||
|
|
|
|||
|
|
@ -113,10 +113,10 @@ public:
|
|||
|
||||
@see ApplicationCommandManager
|
||||
*/
|
||||
KeyPressMappingSet (ApplicationCommandManager* const commandManager);
|
||||
KeyPressMappingSet (ApplicationCommandManager* const commandManager) throw();
|
||||
|
||||
/** Creates an copy of a KeyPressMappingSet. */
|
||||
KeyPressMappingSet (const KeyPressMappingSet& other);
|
||||
KeyPressMappingSet (const KeyPressMappingSet& other) throw();
|
||||
|
||||
/** Destructor. */
|
||||
~KeyPressMappingSet();
|
||||
|
|
@ -146,25 +146,25 @@ public:
|
|||
*/
|
||||
void addKeyPress (const CommandID commandID,
|
||||
const KeyPress& newKeyPress,
|
||||
int insertIndex = -1);
|
||||
int insertIndex = -1) throw();
|
||||
|
||||
/** Reset all mappings to the defaults, as dictated by the ApplicationCommandManager.
|
||||
|
||||
@see resetToDefaultMapping
|
||||
*/
|
||||
void resetToDefaultMappings();
|
||||
void resetToDefaultMappings() throw();
|
||||
|
||||
/** Resets all key-mappings to the defaults for a particular command.
|
||||
|
||||
@see resetToDefaultMappings
|
||||
*/
|
||||
void resetToDefaultMapping (const CommandID commandID);
|
||||
void resetToDefaultMapping (const CommandID commandID) throw();
|
||||
|
||||
/** Removes all keypresses that are assigned to any commands. */
|
||||
void clearAllKeyPresses();
|
||||
void clearAllKeyPresses() throw();
|
||||
|
||||
/** Removes all keypresses that are assigned to a particular command. */
|
||||
void clearAllKeyPresses (const CommandID commandID);
|
||||
void clearAllKeyPresses (const CommandID commandID) throw();
|
||||
|
||||
/** Removes one of the keypresses that are assigned to a command.
|
||||
|
||||
|
|
@ -172,22 +172,22 @@ public:
|
|||
which the keyPressIndex refers.
|
||||
*/
|
||||
void removeKeyPress (const CommandID commandID,
|
||||
const int keyPressIndex);
|
||||
const int keyPressIndex) throw();
|
||||
|
||||
/** Removes a keypress from any command that it may be assigned to.
|
||||
*/
|
||||
void removeKeyPress (const KeyPress& keypress);
|
||||
void removeKeyPress (const KeyPress& keypress) throw();
|
||||
|
||||
/** Returns true if the given command is linked to this key. */
|
||||
bool containsMapping (const CommandID commandID,
|
||||
const KeyPress& keyPress) const;
|
||||
const KeyPress& keyPress) const throw();
|
||||
|
||||
//==============================================================================
|
||||
/** Looks for a command that corresponds to a keypress.
|
||||
|
||||
@returns the UID of the command or 0 if none was found
|
||||
*/
|
||||
CommandID findCommandForKeyPress (const KeyPress& keyPress) const;
|
||||
CommandID findCommandForKeyPress (const KeyPress& keyPress) const throw();
|
||||
|
||||
//==============================================================================
|
||||
/** Tries to recreate the mappings from a previously stored state.
|
||||
|
|
|
|||
|
|
@ -259,16 +259,25 @@ Thread* Thread::getCurrentThread() throw()
|
|||
return result;
|
||||
}
|
||||
|
||||
void Thread::stopAllThreads (const int timeoutInMillisecs) throw()
|
||||
void Thread::stopAllThreads (const int timeOutMilliseconds) throw()
|
||||
{
|
||||
while (getNumRunningThreads() > 0)
|
||||
runningThreadsLock.enter();
|
||||
|
||||
for (int i = runningThreads.size(); --i >= 0;)
|
||||
((Thread*) runningThreads.getUnchecked(i))->signalThreadShouldExit();
|
||||
|
||||
runningThreadsLock.exit();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
runningThreadsLock.enter();
|
||||
Thread* const r = (Thread*) runningThreads[0];
|
||||
Thread* const t = (Thread*) runningThreads[0];
|
||||
runningThreadsLock.exit();
|
||||
|
||||
if (r != 0)
|
||||
r->stopThread (timeoutInMillisecs);
|
||||
if (t == 0)
|
||||
break;
|
||||
|
||||
t->stopThread (timeOutMilliseconds);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue