- Library code update
- project update (added Eigen) git-svn-id: http://moon:8086/svn/software/trunk/projects/mpsk_rx_gui@94 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -138,7 +138,7 @@ String JUCEApplicationBase::getCommandLineParameters() { return String(
|
||||
|
||||
#else
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
#if JUCE_WINDOWS && ! defined (_CONSOLE)
|
||||
|
||||
String JUCE_CALLTYPE JUCEApplicationBase::getCommandLineParameters()
|
||||
{
|
||||
@@ -171,8 +171,13 @@ StringArray JUCE_CALLTYPE JUCEApplicationBase::getCommandLineParameterArray()
|
||||
extern void initialiseNSApplication();
|
||||
#endif
|
||||
|
||||
extern const char* const* juce_argv; // declared in juce_core
|
||||
extern int juce_argc;
|
||||
#if JUCE_WINDOWS
|
||||
const char* const* juce_argv = nullptr;
|
||||
int juce_argc = 0;
|
||||
#else
|
||||
extern const char* const* juce_argv; // declared in juce_core
|
||||
extern int juce_argc;
|
||||
#endif
|
||||
|
||||
String JUCEApplicationBase::getCommandLineParameters()
|
||||
{
|
||||
@@ -227,7 +232,7 @@ int JUCEApplicationBase::main()
|
||||
jassert (app != nullptr);
|
||||
|
||||
if (! app->initialiseApp())
|
||||
return 0;
|
||||
return app->getApplicationReturnValue();
|
||||
|
||||
JUCE_TRY
|
||||
{
|
||||
|
||||
@@ -50,24 +50,24 @@
|
||||
MyJUCEApp() {}
|
||||
~MyJUCEApp() {}
|
||||
|
||||
void initialise (const String& commandLine)
|
||||
void initialise (const String& commandLine) override
|
||||
{
|
||||
myMainWindow = new MyApplicationWindow();
|
||||
myMainWindow->setBounds (100, 100, 400, 500);
|
||||
myMainWindow->setVisible (true);
|
||||
}
|
||||
|
||||
void shutdown()
|
||||
void shutdown() override
|
||||
{
|
||||
myMainWindow = nullptr;
|
||||
}
|
||||
|
||||
const String getApplicationName()
|
||||
const String getApplicationName() override
|
||||
{
|
||||
return "Super JUCE-o-matic";
|
||||
}
|
||||
|
||||
const String getApplicationVersion()
|
||||
const String getApplicationVersion() override
|
||||
{
|
||||
return "1.0";
|
||||
}
|
||||
|
||||
@@ -55,13 +55,17 @@ JUCE_API void JUCE_CALLTYPE shutdownJuce_GUI();
|
||||
/** A utility object that helps you initialise and shutdown Juce correctly
|
||||
using an RAII pattern.
|
||||
|
||||
When an instance of this class is created, it calls initialiseJuce_GUI(),
|
||||
and when it's deleted, it calls shutdownJuce_GUI(), which lets you easily
|
||||
make sure that these functions are matched correctly.
|
||||
When the first instance of this class is created, it calls initialiseJuce_GUI(),
|
||||
and when the last instance is deleted, it calls shutdownJuce_GUI(), so that you
|
||||
can easily be sure that as long as at least one instance of the class exists, the
|
||||
library will be initialised.
|
||||
|
||||
This class is particularly handy to use at the beginning of a console app's
|
||||
main() function, because it'll take care of shutting down whenever you return
|
||||
from the main() call.
|
||||
|
||||
Be careful with your threading though - to be safe, you should always make sure
|
||||
that these objects are created and deleted on the message thread.
|
||||
*/
|
||||
class JUCE_API ScopedJuceInitialiser_GUI
|
||||
{
|
||||
@@ -88,18 +92,12 @@ public:
|
||||
juce::JUCEApplicationBase* juce_CreateApplication() { return new AppClass(); }
|
||||
|
||||
#else
|
||||
#if JUCE_WINDOWS
|
||||
#if defined (WINAPI) || defined (_WINDOWS_)
|
||||
#define JUCE_MAIN_FUNCTION int __stdcall WinMain (HINSTANCE, HINSTANCE, const LPSTR, int)
|
||||
#elif defined (_UNICODE)
|
||||
#define JUCE_MAIN_FUNCTION int __stdcall WinMain (void*, void*, const wchar_t*, int)
|
||||
#else
|
||||
#define JUCE_MAIN_FUNCTION int __stdcall WinMain (void*, void*, const char*, int)
|
||||
#endif
|
||||
#define JUCE_MAIN_FUNCTION_ARGS
|
||||
#if JUCE_WINDOWS && ! defined (_CONSOLE)
|
||||
#define JUCE_MAIN_FUNCTION int __stdcall WinMain (struct HINSTANCE__*, struct HINSTANCE__*, char*, int)
|
||||
#define JUCE_MAIN_FUNCTION_ARGS
|
||||
#else
|
||||
#define JUCE_MAIN_FUNCTION int main (int argc, char* argv[])
|
||||
#define JUCE_MAIN_FUNCTION_ARGS argc, (const char**) argv
|
||||
#define JUCE_MAIN_FUNCTION int main (int argc, char* argv[])
|
||||
#define JUCE_MAIN_FUNCTION_ARGS argc, (const char**) argv
|
||||
#endif
|
||||
|
||||
#define START_JUCE_APPLICATION(AppClass) \
|
||||
|
||||
@@ -66,12 +66,17 @@ void MessageManager::deleteInstance()
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void MessageManager::MessageBase::post()
|
||||
bool MessageManager::MessageBase::post()
|
||||
{
|
||||
MessageManager* const mm = MessageManager::instance;
|
||||
|
||||
if (mm == nullptr || mm->quitMessagePosted || ! postMessageToSystemQueue (this))
|
||||
{
|
||||
Ptr deleter (this); // (this will delete messages that were just created with a 0 ref count)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
@@ -125,6 +130,25 @@ void MessageManager::stopDispatchLoop()
|
||||
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_COMPILER_SUPPORTS_LAMBDAS
|
||||
struct AsyncFunction : private MessageManager::MessageBase
|
||||
{
|
||||
AsyncFunction (std::function<void(void)> f) : fn (f) { post(); }
|
||||
|
||||
private:
|
||||
std::function<void(void)> fn;
|
||||
void messageCallback() override { fn(); }
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AsyncFunction)
|
||||
};
|
||||
|
||||
void MessageManager::callAsync (std::function<void(void)> f)
|
||||
{
|
||||
new AsyncFunction (f);
|
||||
}
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
class AsyncFunctionCallback : public MessageManager::MessageBase
|
||||
{
|
||||
@@ -158,9 +182,15 @@ void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* cons
|
||||
jassert (! currentThreadHasLockedMessageManager());
|
||||
|
||||
const ReferenceCountedObjectPtr<AsyncFunctionCallback> message (new AsyncFunctionCallback (func, parameter));
|
||||
message->post();
|
||||
message->finished.wait();
|
||||
return message->result;
|
||||
|
||||
if (message->post())
|
||||
{
|
||||
message->finished.wait();
|
||||
return message->result;
|
||||
}
|
||||
|
||||
jassertfalse; // the OS message queue failed to send the message!
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
@@ -275,7 +305,12 @@ bool MessageManagerLock::attemptLock (Thread* const threadToCheck, ThreadPoolJob
|
||||
}
|
||||
|
||||
blockingMessage = new BlockingMessage();
|
||||
blockingMessage->post();
|
||||
|
||||
if (! blockingMessage->post())
|
||||
{
|
||||
blockingMessage = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
while (! blockingMessage->lockedEvent.wait (20))
|
||||
{
|
||||
@@ -334,5 +369,7 @@ JUCE_API void JUCE_CALLTYPE shutdownJuce_GUI()
|
||||
}
|
||||
}
|
||||
|
||||
ScopedJuceInitialiser_GUI::ScopedJuceInitialiser_GUI() { initialiseJuce_GUI(); }
|
||||
ScopedJuceInitialiser_GUI::~ScopedJuceInitialiser_GUI() { shutdownJuce_GUI(); }
|
||||
static int numScopedInitInstances = 0;
|
||||
|
||||
ScopedJuceInitialiser_GUI::ScopedJuceInitialiser_GUI() { if (numScopedInitInstances++ == 0) initialiseJuce_GUI(); }
|
||||
ScopedJuceInitialiser_GUI::~ScopedJuceInitialiser_GUI() { if (--numScopedInitInstances == 0) shutdownJuce_GUI(); }
|
||||
|
||||
@@ -91,6 +91,13 @@ public:
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_COMPILER_SUPPORTS_LAMBDAS
|
||||
/** Asynchronously invokes a function or C++11 lambda on the message thread.
|
||||
Internally this uses the CallbackMessage class to invoke the callback.
|
||||
*/
|
||||
static void callAsync (std::function<void(void)>);
|
||||
#endif
|
||||
|
||||
/** Calls a function using the message-thread.
|
||||
|
||||
This can be used by any thread to cause this function to be called-back
|
||||
@@ -170,7 +177,7 @@ public:
|
||||
virtual ~MessageBase() {}
|
||||
|
||||
virtual void messageCallback() = 0;
|
||||
void post();
|
||||
bool post();
|
||||
|
||||
typedef ReferenceCountedObjectPtr<MessageBase> Ptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user