From c20daf9740200f269d5df99be8acfdf907990c04 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Mon, 12 Jul 2010 21:18:14 +0100 Subject: [PATCH] Fixed a mac initialisation problem. --- .../Source/Utility/jucer_PresetIDs.h | 1 + .../juce demo/Source/ApplicationStartup.cpp | 53 +++++------- extras/juce demo/Source/MainDemoWindow.cpp | 54 ++++++------ .../Source/demos/AudioDemoSynthPage.cpp | 2 +- extras/juce demo/Source/demos/CameraDemo.cpp | 14 ++-- .../Source/demos/FontsAndTextDemo.cpp | 10 +-- extras/juce demo/Source/demos/OpenGLDemo.cpp | 2 +- .../juce demo/Source/demos/QuickTimeDemo.cpp | 14 ++-- extras/juce demo/Source/demos/WidgetsDemo.cpp | 8 +- juce_amalgamated.cpp | 84 ++++++++----------- juce_amalgamated.h | 32 +++---- src/application/juce_Application.cpp | 25 ++---- src/application/juce_Application.h | 29 ++----- src/core/juce_Initialisation.h | 4 + .../components/windows/juce_AlertWindow.cpp | 2 +- .../components/windows/juce_DialogWindow.cpp | 2 +- src/native/linux/juce_linux_Messaging.cpp | 6 +- src/native/mac/juce_mac_CoreAudio.cpp | 7 -- src/native/mac/juce_mac_MainMenu.mm | 11 ++- src/native/mac/juce_mac_MessageManager.mm | 11 +-- .../mac/juce_mac_NSViewComponentPeer.mm | 24 +++--- 21 files changed, 165 insertions(+), 230 deletions(-) diff --git a/extras/Jucer (experimental)/Source/Utility/jucer_PresetIDs.h b/extras/Jucer (experimental)/Source/Utility/jucer_PresetIDs.h index 97b056b271..8a14632d62 100644 --- a/extras/Jucer (experimental)/Source/Utility/jucer_PresetIDs.h +++ b/extras/Jucer (experimental)/Source/Utility/jucer_PresetIDs.h @@ -100,6 +100,7 @@ namespace Ids DECLARE_ID (className); DECLARE_ID (classDesc); DECLARE_ID (controlPoint); + DECLARE_ID (createCallback); const Identifier class_ ("class"); const Identifier id_ ("id"); diff --git a/extras/juce demo/Source/ApplicationStartup.cpp b/extras/juce demo/Source/ApplicationStartup.cpp index ce16a13294..463e388a00 100644 --- a/extras/juce demo/Source/ApplicationStartup.cpp +++ b/extras/juce demo/Source/ApplicationStartup.cpp @@ -26,50 +26,30 @@ #include "jucedemo_headers.h" #include "MainDemoWindow.h" + //============================================================================== class JUCEDemoApplication : public JUCEApplication { - /* Important! NEVER embed objects directly inside your JUCEApplication class! Use - ONLY pointers to objects, which you should create during the initialise() method - (NOT in the constructor!) and delete in the shutdown() method (NOT in the - destructor!) - - This is because the application object gets created before Juce has been properly - initialised, so any embedded objects would also get constructed too soon. - */ - MainDemoWindow* theMainWindow; - public: //============================================================================== JUCEDemoApplication() - : theMainWindow (0) { - // NEVER do anything in here that could involve any Juce function being called - // - leave all your startup tasks until the initialise() method. } ~JUCEDemoApplication() { - // Your shutdown() method should already have done all the things necessary to - // clean up this app object, so you should never need to put anything in - // the destructor. - - // Making any Juce calls in here could be very dangerous... } //============================================================================== void initialise (const String& /*commandLine*/) { - // just create the main window... - theMainWindow = new MainDemoWindow(); - -#if JUCE_IPHONE - theMainWindow->setVisible (true); - theMainWindow->setBounds (0, 20, 320, 460); -#else - theMainWindow->centreWithSize (700, 600); -#endif - theMainWindow->setVisible (true); + #if JUCE_IPHONE + theMainWindow.setVisible (true); + theMainWindow.setBounds (0, 20, 320, 460); + #else + theMainWindow.centreWithSize (700, 600); + theMainWindow.setVisible (true); + #endif // this little function just demonstrates a few system info calls Logger::outputDebugString (collectSomeSystemInfo()); @@ -85,18 +65,24 @@ public: void shutdown() { - delete theMainWindow; - theMainWindow = 0; + // This method is where your app should do any cleaning-up that's needed + // before being shut down. } //============================================================================== const String getApplicationName() { - return T("JUCE Demo"); + // When you use the Jucer to auto-generate a project, it puts the project's name and version in + // this constant, so we can use that here as our return value. Alternatively you can return + // your own string here, of course. + return ProjectInfo::projectName; } const String getApplicationVersion() { + // When you use the Jucer to auto-generate a project, it puts the project's name and version in + // this constant, so we can use that here as our return value. Alternatively you can return + // your own string here, of course. return ProjectInfo::versionString; } @@ -112,6 +98,9 @@ public: } private: + // This is the main demo window component. + MainDemoWindow theMainWindow; + //============================================================================== // this little function just demonstrates a few system info calls static const String collectSomeSystemInfo() @@ -131,7 +120,7 @@ private: << "\nCPU has SSE2: " << (SystemStats::hasSSE2() ? "yes" : "no") << "\nCPU has 3DNOW: " << (SystemStats::has3DNow() ? "yes" : "no") << "\nMemory size: " << SystemStats::getMemorySizeInMegabytes() << "MB" - << "\nFound network card MAC addresses: " << SystemStats::getMACAddressStrings().joinIntoString (T(", ")) + << "\nFound network card MAC addresses: " << SystemStats::getMACAddressStrings().joinIntoString (", ") << "\nCurrent executable file: " << File::getSpecialLocation (File::currentExecutableFile).getFullPathName() << "\nCurrent application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName() << "\nCurrent working directory: " << File::getCurrentWorkingDirectory().getFullPathName() diff --git a/extras/juce demo/Source/MainDemoWindow.cpp b/extras/juce demo/Source/MainDemoWindow.cpp index bb4740f75a..ee2b51018f 100644 --- a/extras/juce demo/Source/MainDemoWindow.cpp +++ b/extras/juce demo/Source/MainDemoWindow.cpp @@ -107,9 +107,9 @@ public: //============================================================================== const StringArray getMenuBarNames() { - const tchar* const names[] = { T("Demo"), T("Look-and-feel"), 0 }; + const char* const names[] = { "Demo", "Look-and-feel", 0 }; - return StringArray ((const tchar**) names); + return StringArray (names); } const PopupMenu getMenuForIndex (int menuIndex, const String& /*menuName*/) @@ -224,61 +224,61 @@ public: // that this object can perform.. void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result) { - const String generalCategory (T("General")); - const String demosCategory (T("Demos")); + const String generalCategory ("General"); + const String demosCategory ("Demos"); switch (commandID) { case showRendering: - result.setInfo (T("Graphics Rendering"), T("Shows the graphics demo"), demosCategory, 0); + result.setInfo ("Graphics Rendering", "Shows the graphics demo", demosCategory, 0); result.setTicked (currentDemoId == showRendering); result.addDefaultKeypress (T('1'), ModifierKeys::commandModifier); break; case showFontsAndText: - result.setInfo (T("Fonts and Text"), T("Shows the fonts & text demo"), demosCategory, 0); + result.setInfo ("Fonts and Text", "Shows the fonts & text demo", demosCategory, 0); result.setTicked (currentDemoId == showFontsAndText); result.addDefaultKeypress (T('2'), ModifierKeys::commandModifier); break; case showWidgets: - result.setInfo (T("Widgets"), T("Shows the widgets demo"), demosCategory, 0); + result.setInfo ("Widgets", "Shows the widgets demo", demosCategory, 0); result.setTicked (currentDemoId == showWidgets); result.addDefaultKeypress (T('3'), ModifierKeys::commandModifier); break; case showThreading: - result.setInfo (T("Multithreading"), T("Shows the threading demo"), demosCategory, 0); + result.setInfo ("Multithreading", "Shows the threading demo", demosCategory, 0); result.setTicked (currentDemoId == showThreading); result.addDefaultKeypress (T('4'), ModifierKeys::commandModifier); break; case showTreeView: - result.setInfo (T("Treeviews"), T("Shows the treeviews demo"), demosCategory, 0); + result.setInfo ("Treeviews", "Shows the treeviews demo", demosCategory, 0); result.setTicked (currentDemoId == showTreeView); result.addDefaultKeypress (T('5'), ModifierKeys::commandModifier); break; case showTable: - result.setInfo (T("Table Components"), T("Shows the table component demo"), demosCategory, 0); + result.setInfo ("Table Components", "Shows the table component demo", demosCategory, 0); result.setTicked (currentDemoId == showTable); result.addDefaultKeypress (T('6'), ModifierKeys::commandModifier); break; case showAudio: - result.setInfo (T("Audio"), T("Shows the audio demo"), demosCategory, 0); + result.setInfo ("Audio", "Shows the audio demo", demosCategory, 0); result.setTicked (currentDemoId == showAudio); result.addDefaultKeypress (T('7'), ModifierKeys::commandModifier); break; case showDragAndDrop: - result.setInfo (T("Drag-and-drop"), T("Shows the drag & drop demo"), demosCategory, 0); + result.setInfo ("Drag-and-drop", "Shows the drag & drop demo", demosCategory, 0); result.setTicked (currentDemoId == showDragAndDrop); result.addDefaultKeypress (T('8'), ModifierKeys::commandModifier); break; case showOpenGL: - result.setInfo (T("OpenGL"), T("Shows the OpenGL demo"), demosCategory, 0); + result.setInfo ("OpenGL", "Shows the OpenGL demo", demosCategory, 0); result.addDefaultKeypress (T('9'), ModifierKeys::commandModifier); result.setTicked (currentDemoId == showOpenGL); #if ! JUCE_OPENGL @@ -287,7 +287,7 @@ public: break; case showQuicktime: - result.setInfo (T("Quicktime"), T("Shows the Quicktime demo"), demosCategory, 0); + result.setInfo ("Quicktime", "Shows the Quicktime demo", demosCategory, 0); result.addDefaultKeypress (T('b'), ModifierKeys::commandModifier); result.setTicked (currentDemoId == showQuicktime); #if ! (JUCE_QUICKTIME && ! JUCE_LINUX) @@ -296,7 +296,7 @@ public: break; case showCamera: - result.setInfo (T("Camera Capture"), T("Shows the camera demo"), demosCategory, 0); + result.setInfo ("Camera Capture", "Shows the camera demo", demosCategory, 0); result.addDefaultKeypress (T('c'), ModifierKeys::commandModifier); result.setTicked (currentDemoId == showCamera); #if ! JUCE_USE_CAMERA @@ -305,7 +305,7 @@ public: break; case showWebBrowser: - result.setInfo (T("Web Browser"), T("Shows the web browser demo"), demosCategory, 0); + result.setInfo ("Web Browser", "Shows the web browser demo", demosCategory, 0); result.addDefaultKeypress (T('i'), ModifierKeys::commandModifier); result.setTicked (currentDemoId == showWebBrowser); #if (! JUCE_WEB_BROWSER) || JUCE_LINUX @@ -314,42 +314,42 @@ public: break; case showCodeEditor: - result.setInfo (T("Code Editor"), T("Shows the code editor demo"), demosCategory, 0); + result.setInfo ("Code Editor", "Shows the code editor demo", demosCategory, 0); result.addDefaultKeypress (T('e'), ModifierKeys::commandModifier); result.setTicked (currentDemoId == showCodeEditor); break; case showInterprocessComms: - result.setInfo (T("Interprocess Comms"), T("Shows the interprocess communications demo"), demosCategory, 0); + result.setInfo ("Interprocess Comms", "Shows the interprocess communications demo", demosCategory, 0); result.addDefaultKeypress (T('0'), ModifierKeys::commandModifier); result.setTicked (currentDemoId == showInterprocessComms); break; case setDefaultLookAndFeel: - result.setInfo (T("Use default look-and-feel"), String::empty, generalCategory, 0); + result.setInfo ("Use default look-and-feel", String::empty, generalCategory, 0); result.setTicked ((typeid (LookAndFeel) == typeid (getLookAndFeel())) != 0); break; case setOldSchoolLookAndFeel: - result.setInfo (T("Use the old, original juce look-and-feel"), String::empty, generalCategory, 0); + result.setInfo ("Use the old, original juce look-and-feel", String::empty, generalCategory, 0); result.setTicked ((typeid (OldSchoolLookAndFeel) == typeid (getLookAndFeel())) != 0); break; case useNativeTitleBar: - result.setInfo (T("Use native window title bar"), String::empty, generalCategory, 0); + result.setInfo ("Use native window title bar", String::empty, generalCategory, 0); result.setTicked (mainWindow->isUsingNativeTitleBar()); break; #if JUCE_MAC case useNativeMenus: - result.setInfo (T("Use the native OSX menu bar"), String::empty, generalCategory, 0); + result.setInfo ("Use the native OSX menu bar", String::empty, generalCategory, 0); result.setTicked (MenuBarModel::getMacMainMenu() != 0); break; #endif #if ! JUCE_LINUX case goToKioskMode: - result.setInfo (T("Show full-screen kiosk mode"), String::empty, generalCategory, 0); + result.setInfo ("Show full-screen kiosk mode", String::empty, generalCategory, 0); result.setTicked (Desktop::getInstance().getKioskModeComponent() != 0); break; #endif @@ -509,11 +509,11 @@ public: g.fillAll (Colours::lightblue); g.setColour (Colours::black); g.setFont ((float) icon.getHeight(), Font::bold); - g.drawText (T("j"), 0, 0, icon.getWidth(), icon.getHeight(), Justification::centred, false); + g.drawText ("j", 0, 0, icon.getWidth(), icon.getHeight(), Justification::centred, false); setIconImage (icon); - setIconTooltip (T("Juce Demo App!")); + setIconTooltip ("Juce Demo App!"); } ~DemoTaskbarComponent() @@ -523,7 +523,7 @@ public: void mouseDown (const MouseEvent&) { PopupMenu m; - m.addItem (1, T("Quit the Juce demo")); + m.addItem (1, "Quit the Juce demo"); const int result = m.show(); @@ -536,7 +536,7 @@ public: //============================================================================== MainDemoWindow::MainDemoWindow() - : DocumentWindow (T("JUCE Demo!"), + : DocumentWindow ("JUCE Demo!", Colours::azure, DocumentWindow::allButtons, true) diff --git a/extras/juce demo/Source/demos/AudioDemoSynthPage.cpp b/extras/juce demo/Source/demos/AudioDemoSynthPage.cpp index 81a32f231e..de3a413717 100644 --- a/extras/juce demo/Source/demos/AudioDemoSynthPage.cpp +++ b/extras/juce demo/Source/demos/AudioDemoSynthPage.cpp @@ -203,7 +203,7 @@ public: BigInteger allNotes; allNotes.setRange (0, 128, true); - synth.addSound (new SamplerSound (T("demo sound"), + synth.addSound (new SamplerSound ("demo sound", *audioReader, allNotes, 74, // root midi note diff --git a/extras/juce demo/Source/demos/CameraDemo.cpp b/extras/juce demo/Source/demos/CameraDemo.cpp index 959082d192..1c44d96ccc 100644 --- a/extras/juce demo/Source/demos/CameraDemo.cpp +++ b/extras/juce demo/Source/demos/CameraDemo.cpp @@ -38,22 +38,22 @@ public: //============================================================================== CameraDemo() { - setName (T("Camera")); + setName ("Camera"); cameraDevice = 0; cameraPreviewComp = 0; recordingMovie = false; - addAndMakeVisible (cameraSelectorComboBox = new ComboBox (T("Camera"))); + addAndMakeVisible (cameraSelectorComboBox = new ComboBox ("Camera")); createListOfCameras(); cameraSelectorComboBox->setSelectedId (1); cameraSelectorComboBox->addListener (this); - addAndMakeVisible (snapshotButton = new TextButton (T("Take a snapshot"))); + addAndMakeVisible (snapshotButton = new TextButton ("Take a snapshot")); snapshotButton->addButtonListener (this); snapshotButton->setEnabled (false); - addAndMakeVisible (recordMovieButton = new TextButton (T("Record a movie file (to your desktop)..."))); + addAndMakeVisible (recordMovieButton = new TextButton ("Record a movie file (to your desktop)...")); recordMovieButton->addButtonListener (this); recordMovieButton->setEnabled (false); @@ -133,18 +133,18 @@ public: recordingMovie = true; File file (File::getSpecialLocation (File::userDesktopDirectory) - .getNonexistentChildFile (T("JuceCameraDemo"), + .getNonexistentChildFile ("JuceCameraDemo", CameraDevice::getFileExtension())); cameraDevice->startRecordingToFile (file); - recordMovieButton->setButtonText (T("Stop Recording")); + recordMovieButton->setButtonText ("Stop Recording"); } else { // Already recording, so stop... recordingMovie = false; cameraDevice->stopRecording(); - recordMovieButton->setButtonText (T("Start recording (to a file on your desktop)")); + recordMovieButton->setButtonText ("Start recording (to a file on your desktop)"); } } else diff --git a/extras/juce demo/Source/demos/FontsAndTextDemo.cpp b/extras/juce demo/Source/demos/FontsAndTextDemo.cpp index 6ea4211d07..8a77ceffdd 100644 --- a/extras/juce demo/Source/demos/FontsAndTextDemo.cpp +++ b/extras/juce demo/Source/demos/FontsAndTextDemo.cpp @@ -49,11 +49,11 @@ public: //============================================================================== FontsAndTextDemo() { - setName (T("Fonts")); + setName ("Fonts"); Font::findFonts (fonts); - addAndMakeVisible (listBox = new ListBox (T("fonts"), this)); + addAndMakeVisible (listBox = new ListBox ("fonts", this)); listBox->setRowHeight (28); addAndMakeVisible (textBox = new TextEditor()); @@ -63,12 +63,12 @@ public: textBox->setMultiLine (true, true); textBox->setReturnKeyStartsNewLine (true); - textBox->setText (T("The Quick Brown Fox Jumps Over The Lazy Dog\n\nAa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy Zz 0123456789")); + textBox->setText ("The Quick Brown Fox Jumps Over The Lazy Dog\n\nAa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy Zz 0123456789"); - addAndMakeVisible (boldButton = new ToggleButton (T("bold"))); + addAndMakeVisible (boldButton = new ToggleButton ("bold")); boldButton->addButtonListener (this); - addAndMakeVisible (italicButton = new ToggleButton (T("italic"))); + addAndMakeVisible (italicButton = new ToggleButton ("italic")); italicButton->addButtonListener (this); addAndMakeVisible (sizeSlider = new Slider ("Size")); diff --git a/extras/juce demo/Source/demos/OpenGLDemo.cpp b/extras/juce demo/Source/demos/OpenGLDemo.cpp index 02f5075fca..b6cd71f874 100644 --- a/extras/juce demo/Source/demos/OpenGLDemo.cpp +++ b/extras/juce demo/Source/demos/OpenGLDemo.cpp @@ -271,7 +271,7 @@ public: //============================================================================== OpenGLDemo() { - setName (T("OpenGL")); + setName ("OpenGL"); canvas = new DemoOpenGLCanvas(); addAndMakeVisible (canvas); diff --git a/extras/juce demo/Source/demos/QuickTimeDemo.cpp b/extras/juce demo/Source/demos/QuickTimeDemo.cpp index 72865aea47..6a64e0bac4 100644 --- a/extras/juce demo/Source/demos/QuickTimeDemo.cpp +++ b/extras/juce demo/Source/demos/QuickTimeDemo.cpp @@ -38,14 +38,14 @@ public: addAndMakeVisible (qtComp = new QuickTimeMovieComponent()); // and a file-chooser.. - addAndMakeVisible (fileChooser = new FilenameComponent (T("movie"), + addAndMakeVisible (fileChooser = new FilenameComponent ("movie", File::nonexistent, true, false, false, - T("*.*"), + "*.*", String::empty, - T("(choose a video file to play)"))); + "(choose a video file to play)")); fileChooser->addListener (this); - fileChooser->setBrowseButtonText (T("browse")); + fileChooser->setBrowseButtonText ("browse"); } ~QuickTimeWindowWithFileBrowser() @@ -71,8 +71,8 @@ public: else { AlertWindow::showMessageBox (AlertWindow::WarningIcon, - T("Couldn't load the file!"), - T("Sorry, QuickTime didn't manage to load that file!")); + "Couldn't load the file!", + "Sorry, QuickTime didn't manage to load that file!"); } } @@ -89,7 +89,7 @@ public: //============================================================================== QuickTimeDemo() { - setName (T("QuickTime")); + setName ("QuickTime"); // add a movie component.. addAndMakeVisible (qtComp1 = new QuickTimeWindowWithFileBrowser()); diff --git a/extras/juce demo/Source/demos/WidgetsDemo.cpp b/extras/juce demo/Source/demos/WidgetsDemo.cpp index 463b78cc32..91abba6655 100644 --- a/extras/juce demo/Source/demos/WidgetsDemo.cpp +++ b/extras/juce demo/Source/demos/WidgetsDemo.cpp @@ -513,7 +513,7 @@ public: //============================================================================== // create an image-only button from these drawables.. - db = new DrawableButton (T("Button 2"), DrawableButton::ImageFitted); + db = new DrawableButton ("Button 2", DrawableButton::ImageFitted); db->setImages (&normal, &over, &down); db->setClickingTogglesState (true); @@ -524,7 +524,7 @@ public: //============================================================================== // create an image-on-button-shape button from the same drawables.. - db = new DrawableButton (T("Button 3"), DrawableButton::ImageOnButtonBackground); + db = new DrawableButton ("Button 3", DrawableButton::ImageOnButtonBackground); db->setImages (&normal, 0, 0); addAndMakeVisible (db); @@ -532,7 +532,7 @@ public: db->setTooltip ("this is a DrawableButton on a standard button background"); //============================================================================== - db = new DrawableButton (T("Button 4"), DrawableButton::ImageOnButtonBackground); + db = new DrawableButton ("Button 4", DrawableButton::ImageOnButtonBackground); db->setImages (&normal, &over, &down); db->setClickingTogglesState (true); db->setBackgroundColours (Colours::white, Colours::yellow); @@ -1144,7 +1144,7 @@ public: enableButton = new ToggleButton ("enable/disable components"); addAndMakeVisible (enableButton); enableButton->setBounds (230, 10, 180, 24); - enableButton->setTooltip (T("toggle button")); + enableButton->setTooltip ("toggle button"); enableButton->setToggleState (true, false); enableButton->addButtonListener (this); } diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 73bc3e5698..9311f9b2e8 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -17274,11 +17274,15 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_Application.cpp ***/ BEGIN_JUCE_NAMESPACE +#if JUCE_MAC + extern void juce_initialiseMacMainMenu(); +#endif + JUCEApplication::JUCEApplication() : appReturnValue (0), stillInitialising (true) { - jassert (appInstance == 0); + jassert (isStandaloneApp && appInstance == 0); appInstance = this; } @@ -17294,23 +17298,9 @@ JUCEApplication::~JUCEApplication() appInstance = 0; } +bool JUCEApplication::isStandaloneApp = false; JUCEApplication* JUCEApplication::appInstance = 0; -JUCEApplication* JUCEApplication::getInstance() throw() -{ - return appInstance; -} - -bool JUCEApplication::isInitialising() const throw() -{ - return stillInitialising; -} - -const String JUCEApplication::getApplicationVersion() -{ - return String::empty; -} - bool JUCEApplication::moreThanOneInstanceAllowed() { return true; @@ -17415,6 +17405,10 @@ bool JUCEApplication::initialiseApp (const String& commandLine) // let the app do its setting-up.. initialise (commandLineParameters); +#if JUCE_MAC + juce_initialiseMacMainMenu(); // needs to be called after the app object has created, to get its name +#endif + // register for broadcast new app messages MessageManager::getInstance()->registerBroadcastListener (this); @@ -75819,7 +75813,7 @@ AlertWindow::AlertWindow (const String& title, } } - if (JUCEApplication::getInstance() == 0) + if (! JUCEApplication::isStandaloneApp) setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level lookAndFeelChanged(); @@ -77181,7 +77175,7 @@ public: TempDialogWindow (const String& title, const Colour& colour, const bool escapeCloses) : DialogWindow (title, colour, escapeCloses, true) { - if (JUCEApplication::getInstance() == 0) + if (! JUCEApplication::isStandaloneApp) setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level } @@ -255222,7 +255216,7 @@ namespace LinuxErrorHandling { DBG ("ERROR: connection to X server broken.. terminating."); - if (JUCEApplication::getInstance() != 0) + if (JUCEApplication::isStandaloneApp) MessageManager::getInstance()->stopDispatchLoop(); errorOccurred = true; @@ -255289,7 +255283,7 @@ void MessageManager::doPlatformSpecificInitialisation() // This is fatal! Print error and closedown Logger::outputDebugString ("Failed to initialise xlib thread support."); - if (JUCEApplication::getInstance() != 0) + if (JUCEApplication::isStandaloneApp) Process::terminate(); return; @@ -255391,7 +255385,7 @@ bool juce_dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages) { LinuxErrorHandling::errorOccurred = true; - if (JUCEApplication::getInstance() != 0) + if (JUCEApplication::isStandaloneApp) Process::terminate(); break; @@ -270328,15 +270322,15 @@ END_JUCE_NAMESPACE - (void) mouseDown: (NSEvent*) ev { - // In some host situations, the host will stop modal loops from working - // correctly if they're called from a mouse event, so we'll trigger - // the event asynchronously.. - if (JUCEApplication::getInstance() == 0) + if (JUCEApplication::isStandaloneApp) + [self asyncMouseDown: ev]; + else + // In some host situations, the host will stop modal loops from working + // correctly if they're called from a mouse event, so we'll trigger + // the event asynchronously.. [self performSelectorOnMainThread: @selector (asyncMouseDown:) withObject: ev waitUntilDone: NO]; - else - [self asyncMouseDown: ev]; } - (void) asyncMouseDown: (NSEvent*) ev @@ -270347,15 +270341,15 @@ END_JUCE_NAMESPACE - (void) mouseUp: (NSEvent*) ev { - // In some host situations, the host will stop modal loops from working - // correctly if they're called from a mouse event, so we'll trigger - // the event asynchronously.. - if (JUCEApplication::getInstance() == 0) + if (! JUCEApplication::isStandaloneApp) + [self asyncMouseUp: ev]; + else + // In some host situations, the host will stop modal loops from working + // correctly if they're called from a mouse event, so we'll trigger + // the event asynchronously.. [self performSelectorOnMainThread: @selector (asyncMouseUp:) withObject: ev waitUntilDone: NO]; - else - [self asyncMouseUp: ev]; } - (void) asyncMouseUp: (NSEvent*) ev @@ -273174,14 +273168,14 @@ static NSMenu* createStandardAppMenu (NSMenu* menu, const String& appName, [item release]; item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Hide Others", nil) - action: @selector (hideOtherApplications:) keyEquivalent: @"h"]; + action: @selector (hideOtherApplications:) keyEquivalent: @"h"]; [item setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask]; [item setTarget: NSApp]; [menu addItem: item]; [item release]; item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Show All", nil) - action: @selector (unhideAllApplications:) keyEquivalent: @""]; + action: @selector (unhideAllApplications:) keyEquivalent: @""]; [item setTarget: NSApp]; [menu addItem: item]; [item release]; @@ -273203,7 +273197,7 @@ static NSMenu* createStandardAppMenu (NSMenu* menu, const String& appName, static void rebuildMainMenu (const PopupMenu* extraItems) { // this can't be used in a plugin! - jassert (JUCEApplication::getInstance() != 0); + jassert (JUCEApplication::isStandaloneApp); if (JUCEApplication::getInstance() != 0) { @@ -273261,9 +273255,9 @@ MenuBarModel* MenuBarModel::getMacMainMenu() ? JuceMainMenuHandler::instance->currentModel : 0; } -void initialiseMainMenu() +void juce_initialiseMacMainMenu() { - if (JUCEApplication::getInstance() != 0) // only needed in an app + if (JuceMainMenuHandler::instance == 0) rebuildMainMenu (0); } @@ -274676,7 +274670,7 @@ using namespace JUCE_NAMESPACE; NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; - if (JUCEApplication::getInstance() != 0) + if (JUCEApplication::isStandaloneApp) { oldDelegate = [NSApp delegate]; [NSApp setDelegate: self]; @@ -274922,8 +274916,6 @@ void MessageManager::doPlatformSpecificInitialisation() [NSThread detachNewThreadSelector: @selector (dummyMethod) toTarget: juceAppDelegate withObject: nil]; - - initialiseMainMenu(); } void MessageManager::doPlatformSpecificShutdown() @@ -274947,8 +274939,7 @@ void MessageManager::broadcastMessage (const String& value) throw() { } -void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback, - void* data) +void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback, void* data) { if (isThisTheMessageThread()) { @@ -276402,7 +276393,6 @@ public: if (OK (AudioObjectGetPropertyData (kAudioObjectSystemObject, &pa, 0, 0, &size, devs))) { - static bool alreadyLogged = false; const int num = size / (int) sizeof (AudioDeviceID); for (int i = 0; i < num; ++i) { @@ -276413,10 +276403,6 @@ public: if (OK (AudioObjectGetPropertyData (devs[i], &pa, 0, 0, &size, name))) { const String nameString (String::fromUTF8 (name, (int) strlen (name))); - - if (! alreadyLogged) - log ("CoreAudio device: " + nameString); - const int numIns = getNumChannels (devs[i], true); const int numOuts = getNumChannels (devs[i], false); @@ -276433,8 +276419,6 @@ public: } } } - - alreadyLogged = true; } } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 1c92e77bd3..18b4f27181 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -13742,6 +13742,7 @@ public: #define START_JUCE_APPLICATION(AppClass) \ int main (int argc, char* argv[]) \ { \ + JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ return JUCE_NAMESPACE::JUCEApplication::main (argc, (const char**) argv, new AppClass()); \ } @@ -13752,6 +13753,7 @@ public: #define START_JUCE_APPLICATION(AppClass) \ int main (int, char* argv[]) \ { \ + JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ } @@ -13760,6 +13762,7 @@ public: #define START_JUCE_APPLICATION(AppClass) \ int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int) \ { \ + JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ } @@ -13767,6 +13770,7 @@ public: #define START_JUCE_APPLICATION(AppClass) \ int __stdcall WinMain (int, int, const char*, int) \ { \ + JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ } @@ -27935,22 +27939,16 @@ public: e.g. @code class MyJUCEApp : public JUCEApplication { - // NEVER put objects inside a JUCEApplication class - only use pointers to - // objects, which you must create in the initialise() method. MyApplicationWindow* myMainWindow; public: MyJUCEApp() : myMainWindow (0) { - // never create any Juce objects in the constructor - do all your initialisation - // in the initialise() method. } ~MyJUCEApp() { - // all your shutdown code must have already been done in the shutdown() method - - // nothing should happen in this destructor. } void initialise (const String& commandLine) @@ -27980,12 +27978,6 @@ public: START_JUCE_APPLICATION (MyJUCEApp) @endcode - Because this object will be created before Juce has properly initialised, you must - NEVER add any member variable objects that will be automatically constructed. Likewise - don't put ANY code in the constructor that could call Juce functions. Any objects that - you want to add to the class must be pointers, which you should instantiate during the - initialise() method, and delete in the shutdown() method. - @see MessageManager, DeletedAtShutdown */ class JUCE_API JUCEApplication : public ApplicationCommandTarget, @@ -28011,7 +28003,7 @@ public: virtual ~JUCEApplication(); /** Returns the global instance of the application object being run. */ - static JUCEApplication* getInstance() throw(); + static JUCEApplication* getInstance() throw() { return appInstance; } /** Called when the application starts. @@ -28038,7 +28030,7 @@ public: This is handy for things like splash screens to know when the app's up-and-running properly. */ - bool isInitialising() const throw(); + bool isInitialising() const throw() { return stillInitialising; } /* Called to allow the application to clear up before exiting. @@ -28061,11 +28053,8 @@ public: virtual const String getApplicationName() = 0; /** Returns the application's version number. - - An application can implement this to give itself a version. - (The default implementation of this just returns an empty string). */ - virtual const String getApplicationVersion(); + virtual const String getApplicationVersion() = 0; /** Checks whether multiple instances of the app are allowed. @@ -28150,11 +28139,8 @@ public: static int main (const String& commandLine, JUCEApplication* newApp); /** @internal */ static int main (int argc, const char* argv[], JUCEApplication* newApp); - /** @internal */ - static void sendUnhandledException (const std::exception* e, - const char* sourceFile, - int lineNumber); + static void sendUnhandledException (const std::exception* e, const char* sourceFile, int lineNumber); /** @internal */ ApplicationCommandTarget* getNextCommandTarget(); @@ -28170,6 +28156,8 @@ public: bool initialiseApp (const String& commandLine); /** @internal */ int shutdownApp(); + /** @internal */ + static bool isStandaloneApp; private: diff --git a/src/application/juce_Application.cpp b/src/application/juce_Application.cpp index b1d2802e91..f6c4f72f92 100644 --- a/src/application/juce_Application.cpp +++ b/src/application/juce_Application.cpp @@ -36,13 +36,16 @@ BEGIN_JUCE_NAMESPACE #include "../core/juce_PlatformUtilities.h" #include "../text/juce_LocalisedStrings.h" +#if JUCE_MAC + extern void juce_initialiseMacMainMenu(); +#endif //============================================================================== JUCEApplication::JUCEApplication() : appReturnValue (0), stillInitialising (true) { - jassert (appInstance == 0); + jassert (isStandaloneApp && appInstance == 0); appInstance = this; } @@ -58,24 +61,10 @@ JUCEApplication::~JUCEApplication() appInstance = 0; } +bool JUCEApplication::isStandaloneApp = false; JUCEApplication* JUCEApplication::appInstance = 0; -JUCEApplication* JUCEApplication::getInstance() throw() -{ - return appInstance; -} - -bool JUCEApplication::isInitialising() const throw() -{ - return stillInitialising; -} - //============================================================================== -const String JUCEApplication::getApplicationVersion() -{ - return String::empty; -} - bool JUCEApplication::moreThanOneInstanceAllowed() { return true; @@ -183,6 +172,10 @@ bool JUCEApplication::initialiseApp (const String& commandLine) // let the app do its setting-up.. initialise (commandLineParameters); +#if JUCE_MAC + juce_initialiseMacMainMenu(); // needs to be called after the app object has created, to get its name +#endif + // register for broadcast new app messages MessageManager::getInstance()->registerBroadcastListener (this); diff --git a/src/application/juce_Application.h b/src/application/juce_Application.h index 345f5c8fbc..3927305e04 100644 --- a/src/application/juce_Application.h +++ b/src/application/juce_Application.h @@ -46,22 +46,16 @@ e.g. @code class MyJUCEApp : public JUCEApplication { - // NEVER put objects inside a JUCEApplication class - only use pointers to - // objects, which you must create in the initialise() method. MyApplicationWindow* myMainWindow; public: MyJUCEApp() : myMainWindow (0) { - // never create any Juce objects in the constructor - do all your initialisation - // in the initialise() method. } ~MyJUCEApp() { - // all your shutdown code must have already been done in the shutdown() method - - // nothing should happen in this destructor. } void initialise (const String& commandLine) @@ -91,12 +85,6 @@ START_JUCE_APPLICATION (MyJUCEApp) @endcode - Because this object will be created before Juce has properly initialised, you must - NEVER add any member variable objects that will be automatically constructed. Likewise - don't put ANY code in the constructor that could call Juce functions. Any objects that - you want to add to the class must be pointers, which you should instantiate during the - initialise() method, and delete in the shutdown() method. - @see MessageManager, DeletedAtShutdown */ class JUCE_API JUCEApplication : public ApplicationCommandTarget, @@ -123,7 +111,7 @@ public: //============================================================================== /** Returns the global instance of the application object being run. */ - static JUCEApplication* getInstance() throw(); + static JUCEApplication* getInstance() throw() { return appInstance; } //============================================================================== /** Called when the application starts. @@ -151,7 +139,7 @@ public: This is handy for things like splash screens to know when the app's up-and-running properly. */ - bool isInitialising() const throw(); + bool isInitialising() const throw() { return stillInitialising; } /* Called to allow the application to clear up before exiting. @@ -175,11 +163,8 @@ public: virtual const String getApplicationName() = 0; /** Returns the application's version number. - - An application can implement this to give itself a version. - (The default implementation of this just returns an empty string). */ - virtual const String getApplicationVersion(); + virtual const String getApplicationVersion() = 0; /** Checks whether multiple instances of the app are allowed. @@ -266,13 +251,9 @@ public: static int main (const String& commandLine, JUCEApplication* newApp); /** @internal */ static int main (int argc, const char* argv[], JUCEApplication* newApp); - /** @internal */ - static void sendUnhandledException (const std::exception* e, - const char* sourceFile, - int lineNumber); + static void sendUnhandledException (const std::exception* e, const char* sourceFile, int lineNumber); - //============================================================================== /** @internal */ ApplicationCommandTarget* getNextCommandTarget(); /** @internal */ @@ -287,6 +268,8 @@ public: bool initialiseApp (const String& commandLine); /** @internal */ int shutdownApp(); + /** @internal */ + static bool isStandaloneApp; private: //============================================================================== diff --git a/src/core/juce_Initialisation.h b/src/core/juce_Initialisation.h index 17c9930b52..69d799ad89 100644 --- a/src/core/juce_Initialisation.h +++ b/src/core/juce_Initialisation.h @@ -139,6 +139,7 @@ public: #define START_JUCE_APPLICATION(AppClass) \ int main (int argc, char* argv[]) \ { \ + JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ return JUCE_NAMESPACE::JUCEApplication::main (argc, (const char**) argv, new AppClass()); \ } @@ -149,6 +150,7 @@ public: #define START_JUCE_APPLICATION(AppClass) \ int main (int, char* argv[]) \ { \ + JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ } @@ -157,6 +159,7 @@ public: #define START_JUCE_APPLICATION(AppClass) \ int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int) \ { \ + JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ } @@ -164,6 +167,7 @@ public: #define START_JUCE_APPLICATION(AppClass) \ int __stdcall WinMain (int, int, const char*, int) \ { \ + JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ } diff --git a/src/gui/components/windows/juce_AlertWindow.cpp b/src/gui/components/windows/juce_AlertWindow.cpp index 64a4e91456..e0207865cf 100644 --- a/src/gui/components/windows/juce_AlertWindow.cpp +++ b/src/gui/components/windows/juce_AlertWindow.cpp @@ -106,7 +106,7 @@ AlertWindow::AlertWindow (const String& title, } } - if (JUCEApplication::getInstance() == 0) + if (! JUCEApplication::isStandaloneApp) setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level lookAndFeelChanged(); diff --git a/src/gui/components/windows/juce_DialogWindow.cpp b/src/gui/components/windows/juce_DialogWindow.cpp index 98e92d5944..d102daac60 100644 --- a/src/gui/components/windows/juce_DialogWindow.cpp +++ b/src/gui/components/windows/juce_DialogWindow.cpp @@ -68,7 +68,7 @@ public: TempDialogWindow (const String& title, const Colour& colour, const bool escapeCloses) : DialogWindow (title, colour, escapeCloses, true) { - if (JUCEApplication::getInstance() == 0) + if (! JUCEApplication::isStandaloneApp) setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level } diff --git a/src/native/linux/juce_linux_Messaging.cpp b/src/native/linux/juce_linux_Messaging.cpp index 622ba5161d..6fcfc0a779 100644 --- a/src/native/linux/juce_linux_Messaging.cpp +++ b/src/native/linux/juce_linux_Messaging.cpp @@ -253,7 +253,7 @@ namespace LinuxErrorHandling { DBG ("ERROR: connection to X server broken.. terminating."); - if (JUCEApplication::getInstance() != 0) + if (JUCEApplication::isStandaloneApp) MessageManager::getInstance()->stopDispatchLoop(); errorOccurred = true; @@ -322,7 +322,7 @@ void MessageManager::doPlatformSpecificInitialisation() // This is fatal! Print error and closedown Logger::outputDebugString ("Failed to initialise xlib thread support."); - if (JUCEApplication::getInstance() != 0) + if (JUCEApplication::isStandaloneApp) Process::terminate(); return; @@ -424,7 +424,7 @@ bool juce_dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages) { LinuxErrorHandling::errorOccurred = true; - if (JUCEApplication::getInstance() != 0) + if (JUCEApplication::isStandaloneApp) Process::terminate(); break; diff --git a/src/native/mac/juce_mac_CoreAudio.cpp b/src/native/mac/juce_mac_CoreAudio.cpp index f2e4d9a45e..134ed445ce 100644 --- a/src/native/mac/juce_mac_CoreAudio.cpp +++ b/src/native/mac/juce_mac_CoreAudio.cpp @@ -1145,7 +1145,6 @@ public: if (OK (AudioObjectGetPropertyData (kAudioObjectSystemObject, &pa, 0, 0, &size, devs))) { - static bool alreadyLogged = false; const int num = size / (int) sizeof (AudioDeviceID); for (int i = 0; i < num; ++i) { @@ -1156,10 +1155,6 @@ public: if (OK (AudioObjectGetPropertyData (devs[i], &pa, 0, 0, &size, name))) { const String nameString (String::fromUTF8 (name, (int) strlen (name))); - - if (! alreadyLogged) - log ("CoreAudio device: " + nameString); - const int numIns = getNumChannels (devs[i], true); const int numOuts = getNumChannels (devs[i], false); @@ -1176,8 +1171,6 @@ public: } } } - - alreadyLogged = true; } } diff --git a/src/native/mac/juce_mac_MainMenu.mm b/src/native/mac/juce_mac_MainMenu.mm index 9acb53a543..ffb917797c 100644 --- a/src/native/mac/juce_mac_MainMenu.mm +++ b/src/native/mac/juce_mac_MainMenu.mm @@ -456,14 +456,14 @@ static NSMenu* createStandardAppMenu (NSMenu* menu, const String& appName, [item release]; item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Hide Others", nil) - action: @selector (hideOtherApplications:) keyEquivalent: @"h"]; + action: @selector (hideOtherApplications:) keyEquivalent: @"h"]; [item setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask]; [item setTarget: NSApp]; [menu addItem: item]; [item release]; item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Show All", nil) - action: @selector (unhideAllApplications:) keyEquivalent: @""]; + action: @selector (unhideAllApplications:) keyEquivalent: @""]; [item setTarget: NSApp]; [menu addItem: item]; [item release]; @@ -485,7 +485,7 @@ static NSMenu* createStandardAppMenu (NSMenu* menu, const String& appName, static void rebuildMainMenu (const PopupMenu* extraItems) { // this can't be used in a plugin! - jassert (JUCEApplication::getInstance() != 0); + jassert (JUCEApplication::isStandaloneApp); if (JUCEApplication::getInstance() != 0) { @@ -543,10 +543,9 @@ MenuBarModel* MenuBarModel::getMacMainMenu() ? JuceMainMenuHandler::instance->currentModel : 0; } - -void initialiseMainMenu() +void juce_initialiseMacMainMenu() { - if (JUCEApplication::getInstance() != 0) // only needed in an app + if (JuceMainMenuHandler::instance == 0) rebuildMainMenu (0); } diff --git a/src/native/mac/juce_mac_MessageManager.mm b/src/native/mac/juce_mac_MessageManager.mm index 77c1ddfcd9..e5903d07ed 100644 --- a/src/native/mac/juce_mac_MessageManager.mm +++ b/src/native/mac/juce_mac_MessageManager.mm @@ -27,6 +27,8 @@ // compiled on its own). #if JUCE_INCLUDED_FILE + +//============================================================================== /* When you use multiple DLLs which share similarly-named obj-c classes - like for example having more than one juce plugin loaded into a host, then when a method is called, the actual code that runs might actually be in a different module @@ -170,6 +172,7 @@ using namespace JUCE_NAMESPACE; #define JuceAppDelegate MakeObjCClassName(JuceAppDelegate) +//============================================================================== @interface JuceAppDelegate : NSObject { @private @@ -201,7 +204,7 @@ using namespace JUCE_NAMESPACE; NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; - if (JUCEApplication::getInstance() != 0) + if (JUCEApplication::isStandaloneApp) { oldDelegate = [NSApp delegate]; [NSApp setDelegate: self]; @@ -287,6 +290,7 @@ using namespace JUCE_NAMESPACE; @end +//============================================================================== BEGIN_JUCE_NAMESPACE static JuceAppDelegate* juceAppDelegate = 0; @@ -448,8 +452,6 @@ void MessageManager::doPlatformSpecificInitialisation() [NSThread detachNewThreadSelector: @selector (dummyMethod) toTarget: juceAppDelegate withObject: nil]; - - initialiseMainMenu(); } void MessageManager::doPlatformSpecificShutdown() @@ -473,8 +475,7 @@ void MessageManager::broadcastMessage (const String& value) throw() { } -void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback, - void* data) +void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback, void* data) { if (isThisTheMessageThread()) { diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index 0b1d1afaad..3c6d4ec87d 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -328,15 +328,15 @@ END_JUCE_NAMESPACE //============================================================================== - (void) mouseDown: (NSEvent*) ev { - // In some host situations, the host will stop modal loops from working - // correctly if they're called from a mouse event, so we'll trigger - // the event asynchronously.. - if (JUCEApplication::getInstance() == 0) + if (JUCEApplication::isStandaloneApp) + [self asyncMouseDown: ev]; + else + // In some host situations, the host will stop modal loops from working + // correctly if they're called from a mouse event, so we'll trigger + // the event asynchronously.. [self performSelectorOnMainThread: @selector (asyncMouseDown:) withObject: ev waitUntilDone: NO]; - else - [self asyncMouseDown: ev]; } - (void) asyncMouseDown: (NSEvent*) ev @@ -347,15 +347,15 @@ END_JUCE_NAMESPACE - (void) mouseUp: (NSEvent*) ev { - // In some host situations, the host will stop modal loops from working - // correctly if they're called from a mouse event, so we'll trigger - // the event asynchronously.. - if (JUCEApplication::getInstance() == 0) + if (! JUCEApplication::isStandaloneApp) + [self asyncMouseUp: ev]; + else + // In some host situations, the host will stop modal loops from working + // correctly if they're called from a mouse event, so we'll trigger + // the event asynchronously.. [self performSelectorOnMainThread: @selector (asyncMouseUp:) withObject: ev waitUntilDone: NO]; - else - [self asyncMouseUp: ev]; } - (void) asyncMouseUp: (NSEvent*) ev