diff --git a/build/linux/platform_specific_code/juce_linux_Threads.cpp b/build/linux/platform_specific_code/juce_linux_Threads.cpp index 255dcfe277..4b292d294b 100644 --- a/build/linux/platform_specific_code/juce_linux_Threads.cpp +++ b/build/linux/platform_specific_code/juce_linux_Threads.cpp @@ -240,7 +240,7 @@ bool WaitableEvent::wait (const int timeOutMillisecs) const throw() bool ok = true; pthread_mutex_lock (&es->mutex); - if (!es->triggered) + if (! es->triggered) { if (timeOutMillisecs < 0) { @@ -252,28 +252,31 @@ bool WaitableEvent::wait (const int timeOutMillisecs) const throw() struct timeval t; int timeout = 0; - gettimeofday(&t,NULL); + gettimeofday (&t, 0); time.tv_sec = t.tv_sec + (timeOutMillisecs / 1000); - time.tv_nsec = (t.tv_usec + ((timeOutMillisecs % 1000)*1000)) * 1000; - while( time.tv_nsec >= 1000000000 ) + time.tv_nsec = (t.tv_usec + ((timeOutMillisecs % 1000) * 1000)) * 1000; + + while (time.tv_nsec >= 1000000000) { time.tv_nsec -= 1000000000; time.tv_sec++; } - while( !timeout ) + while (! timeout) { timeout = pthread_cond_timedwait (&es->condition, &es->mutex, &time); - if( !timeout ) + + if (! timeout) // Success break; - if( timeout == EINTR ) + if (timeout == EINTR) // Go round again timeout = 0; } } + ok = es->triggered; } @@ -377,7 +380,7 @@ void* Process::getProcedureEntryPoint (void* libraryHandle, const String& proced //============================================================================== -InterProcessLock::InterProcessLock (const String& name_) +InterProcessLock::InterProcessLock (const String& name_) throw() : internal (0), name (name_), reentrancyLevel (0) @@ -389,7 +392,7 @@ InterProcessLock::InterProcessLock (const String& name_) internal = (void*) open (temp.getFullPathName().toUTF8(), 'a'); } -InterProcessLock::~InterProcessLock() +InterProcessLock::~InterProcessLock() throw() { while (reentrancyLevel > 0) this->exit(); @@ -401,7 +404,7 @@ InterProcessLock::~InterProcessLock() #endif } -bool InterProcessLock::enter (int timeOutMillisecs) +bool InterProcessLock::enter (const int timeOutMillisecs) throw() { if (internal == 0) return false; @@ -441,7 +444,7 @@ bool InterProcessLock::enter (int timeOutMillisecs) return false; } -void InterProcessLock::exit() +void InterProcessLock::exit() throw() { if (reentrancyLevel > 0 && internal != 0) { diff --git a/build/macosx/platform_specific_code/juce_mac_Threads.cpp b/build/macosx/platform_specific_code/juce_mac_Threads.cpp index f69495150d..8558b736d8 100644 --- a/build/macosx/platform_specific_code/juce_mac_Threads.cpp +++ b/build/macosx/platform_specific_code/juce_mac_Threads.cpp @@ -111,7 +111,7 @@ bool WaitableEvent::wait (const int timeOutMillisecs) const throw() bool ok = true; pthread_mutex_lock (&es->mutex); - if (!es->triggered) + if (! es->triggered) { if (timeOutMillisecs < 0) { @@ -289,7 +289,7 @@ void* Process::getProcedureEntryPoint (void* h, const String& procedureName) } //============================================================================== -InterProcessLock::InterProcessLock (const String& name_) +InterProcessLock::InterProcessLock (const String& name_) throw() : internal (0), name (name_), reentrancyLevel (0) @@ -301,7 +301,7 @@ InterProcessLock::InterProcessLock (const String& name_) internal = (void*) open (temp.getFullPathName().toUTF8(), O_NONBLOCK | O_RDONLY); } -InterProcessLock::~InterProcessLock() +InterProcessLock::~InterProcessLock() throw() { while (reentrancyLevel > 0) this->exit(); @@ -309,7 +309,7 @@ InterProcessLock::~InterProcessLock() close ((int) internal); } -bool InterProcessLock::enter (int timeOutMillisecs) +bool InterProcessLock::enter (const int timeOutMillisecs) throw() { if (internal == 0) return false; @@ -349,7 +349,7 @@ bool InterProcessLock::enter (int timeOutMillisecs) return false; } -void InterProcessLock::exit() +void InterProcessLock::exit() throw() { if (reentrancyLevel > 0 && internal != 0) { diff --git a/build/macosx/platform_specific_code/juce_mac_Windowing.cpp b/build/macosx/platform_specific_code/juce_mac_Windowing.cpp index 587b27ac69..0a7e8b1cfe 100644 --- a/build/macosx/platform_specific_code/juce_mac_Windowing.cpp +++ b/build/macosx/platform_specific_code/juce_mac_Windowing.cpp @@ -2226,8 +2226,15 @@ void Desktop::getMousePosition (int& x, int& y) throw() void Desktop::setMousePosition (int x, int y) throw() { + // this rubbish needs to be done around the warp call, to avoid causing a + // bizarre glitch.. + CGAssociateMouseAndMouseCursorPosition (false); + CGSetLocalEventsSuppressionInterval (0); + CGPoint pos = { x, y }; - CGWarpMouseCursorPosition (pos); + CGWarpMouseCursorPosition (pos); + + CGAssociateMouseAndMouseCursorPosition (true); } const ModifierKeys ModifierKeys::getCurrentModifiersRealtime() throw() diff --git a/build/win32/platform_specific_code/juce_win32_DirectSound.cpp b/build/win32/platform_specific_code/juce_win32_DirectSound.cpp index 6bc7e3aab2..7928e21743 100644 --- a/build/win32/platform_specific_code/juce_win32_DirectSound.cpp +++ b/build/win32/platform_specific_code/juce_win32_DirectSound.cpp @@ -208,7 +208,7 @@ static const String getDSErrorMessage (HRESULT hr) break; default: - return T("Unknown error: ") + String ((int) hr); + return "Unknown error: " + String ((int) hr); } return result; diff --git a/build/win32/platform_specific_code/juce_win32_Midi.cpp b/build/win32/platform_specific_code/juce_win32_Midi.cpp index 9f004d1b61..07154898dd 100644 --- a/build/win32/platform_specific_code/juce_win32_Midi.cpp +++ b/build/win32/platform_specific_code/juce_win32_Midi.cpp @@ -192,6 +192,8 @@ public: lock.exit(); +//xxx needs to figure out if blocks are broken up or not + if (len == 0) { wait (500); diff --git a/build/win32/platform_specific_code/juce_win32_Threads.cpp b/build/win32/platform_specific_code/juce_win32_Threads.cpp index 1e84fff9f2..d63c76404d 100644 --- a/build/win32/platform_specific_code/juce_win32_Threads.cpp +++ b/build/win32/platform_specific_code/juce_win32_Threads.cpp @@ -91,8 +91,8 @@ void CriticalSection::exit() const throw() //============================================================================== WaitableEvent::WaitableEvent() throw() + : internal (CreateEvent (0, FALSE, FALSE, 0)) { - internal = CreateEvent (0, FALSE, FALSE, 0); } WaitableEvent::~WaitableEvent() throw() @@ -341,19 +341,19 @@ void* Process::getProcedureEntryPoint (void* h, const String& name) //============================================================================== -InterProcessLock::InterProcessLock (const String& name_) +InterProcessLock::InterProcessLock (const String& name_) throw() : internal (0), name (name_), reentrancyLevel (0) { } -InterProcessLock::~InterProcessLock() +InterProcessLock::~InterProcessLock() throw() { exit(); } -bool InterProcessLock::enter (int timeOutMillisecs) +bool InterProcessLock::enter (const int timeOutMillisecs) throw() { if (reentrancyLevel++ == 0) { @@ -375,7 +375,7 @@ bool InterProcessLock::enter (int timeOutMillisecs) return (internal != 0); } -void InterProcessLock::exit() +void InterProcessLock::exit() throw() { if (--reentrancyLevel == 0 && internal != 0) { diff --git a/build/win32/platform_specific_code/juce_win32_Windowing.cpp b/build/win32/platform_specific_code/juce_win32_Windowing.cpp index d0c40ca077..90af4f1f80 100644 --- a/build/win32/platform_specific_code/juce_win32_Windowing.cpp +++ b/build/win32/platform_specific_code/juce_win32_Windowing.cpp @@ -420,6 +420,7 @@ long improbableWindowNumber = 0xf965aa01; // also referenced by messaging.cpp //============================================================================== static int currentModifiers = 0; +static int modifiersAtLastCallback = 0; static void updateKeyModifiers() throw() { @@ -1549,6 +1550,15 @@ private: } //============================================================================== + void sendModifierKeyChangeIfNeeded() + { + if (modifiersAtLastCallback != currentModifiers) + { + modifiersAtLastCallback = currentModifiers; + handleModifierKeysChange(); + } + } + bool doKeyUp (const WPARAM key) { updateKeyModifiers(); @@ -1570,7 +1580,7 @@ private: case VK_LMENU: case VK_RCONTROL: case VK_RMENU: - handleModifierKeysChange(); + sendModifierKeyChangeIfNeeded(); } return handleKeyUpOrDown(); @@ -1598,7 +1608,7 @@ private: case VK_NUMLOCK: case VK_SCROLL: case VK_APPS: - handleModifierKeysChange(); + sendModifierKeyChangeIfNeeded(); break; case VK_LEFT: @@ -1976,11 +1986,13 @@ private: juce_repeatLastProcessPriority(); juce_CheckCurrentlyFocusedTopLevelWindow(); + modifiersAtLastCallback = -1; return 0; case WM_ACTIVATE: if (LOWORD (wParam) == WA_ACTIVE || LOWORD (wParam) == WA_CLICKACTIVE) { + modifiersAtLastCallback = -1; updateKeyModifiers(); if (isMinimised()) diff --git a/extras/audio plugins/wrapper/formats/RTAS/juce_RTASWrapper.cpp b/extras/audio plugins/wrapper/formats/RTAS/juce_RTASWrapper.cpp index 4c3a98d860..ecc6d287ce 100644 --- a/extras/audio plugins/wrapper/formats/RTAS/juce_RTASWrapper.cpp +++ b/extras/audio plugins/wrapper/formats/RTAS/juce_RTASWrapper.cpp @@ -244,6 +244,10 @@ public: { PopupMenu::dismissAllActiveMenus(); + Component* const modalComponent = Component::getCurrentlyModalComponent(); + if (modalComponent != 0) + modalComponent->exitModalState (0); + filter->editorBeingDeleted (editorComp); deleteAndZero (editorComp); deleteAndZero (wrapper); diff --git a/extras/audio plugins/wrapper/formats/VST/juce_VstWrapper.cpp b/extras/audio plugins/wrapper/formats/VST/juce_VstWrapper.cpp index 230f3bebfe..57bb4da62b 100644 --- a/extras/audio plugins/wrapper/formats/VST/juce_VstWrapper.cpp +++ b/extras/audio plugins/wrapper/formats/VST/juce_VstWrapper.cpp @@ -901,15 +901,19 @@ public: const MessageManagerLock mml; #endif - Component* modalComponent = Component::getCurrentlyModalComponent(); - if (modalComponent != 0) - modalComponent->exitModalState (0); - if (editorComp != 0) { + Component* const modalComponent = Component::getCurrentlyModalComponent(); + if (modalComponent != 0) + modalComponent->exitModalState (0); + filter->editorBeingDeleted (editorComp->getEditorComp()); deleteAndZero (editorComp); + + // there's some kind of component currently modal, but the host + // is trying to delete our plugin. You should try to avoid this happening.. + jassert (Component::getCurrentlyModalComponent() == 0); } #if JUCE_MAC || JUCE_LINUX @@ -917,10 +921,6 @@ public: #endif recursionCheck = false; - - // there's some kind of component currently modal, but the host - // is trying to delete our plugin. You should try to avoid this happening.. - jassert (Component::getCurrentlyModalComponent() == 0); } VstIntPtr dispatcher (VstInt32 opCode, VstInt32 index, VstIntPtr value, void* ptr, float opt) diff --git a/src/juce_appframework/application/juce_Application.cpp b/src/juce_appframework/application/juce_Application.cpp index 40bd1394e4..f297853c45 100644 --- a/src/juce_appframework/application/juce_Application.cpp +++ b/src/juce_appframework/application/juce_Application.cpp @@ -181,7 +181,7 @@ int JUCEApplication::main (String& commandLine, JUCEApplication* const app) if (! app->moreThanOneInstanceAllowed()) { - appLock = new InterProcessLock (T("juceAppLock_") + app->getApplicationName()); + appLock = new InterProcessLock ("juceAppLock_" + app->getApplicationName()); if (! appLock->enter(0)) { diff --git a/src/juce_appframework/gui/components/windows/juce_SplashScreen.h b/src/juce_appframework/gui/components/windows/juce_SplashScreen.h index e47e084c21..d595d8be5b 100644 --- a/src/juce_appframework/gui/components/windows/juce_SplashScreen.h +++ b/src/juce_appframework/gui/components/windows/juce_SplashScreen.h @@ -63,7 +63,7 @@ @endcode */ class JUCE_API SplashScreen : public Component, - private Timer, + public Timer, private DeletedAtShutdown { public: @@ -132,8 +132,8 @@ public: const bool useDropShadow); //============================================================================== + /** @internal */ void paint (Graphics& g); - /** @internal */ void timerCallback(); diff --git a/src/juce_core/basics/juce_SystemStats.cpp b/src/juce_core/basics/juce_SystemStats.cpp index d985f29183..fdee3799c4 100644 --- a/src/juce_core/basics/juce_SystemStats.cpp +++ b/src/juce_core/basics/juce_SystemStats.cpp @@ -45,7 +45,7 @@ BEGIN_JUCE_NAMESPACE //============================================================================== const String SystemStats::getJUCEVersion() throw() { - return T("JUCE v") + String (JUCE_MAJOR_VERSION) + "." + String (JUCE_MINOR_VERSION); + return "JUCE v" + String (JUCE_MAJOR_VERSION) + "." + String (JUCE_MINOR_VERSION); } diff --git a/src/juce_core/io/network/juce_URL.cpp b/src/juce_core/io/network/juce_URL.cpp index 221106e1e3..a5c17c020b 100644 --- a/src/juce_core/io/network/juce_URL.cpp +++ b/src/juce_core/io/network/juce_URL.cpp @@ -417,7 +417,7 @@ bool URL::launchInDefaultBrowser() const String u (toString (true)); if (u.contains (T("@")) && ! u.contains (T(":"))) - u = T("mailto:") + u; + u = "mailto:" + u; return juce_launchFile (u, String::empty); } diff --git a/src/juce_core/text/juce_String.cpp b/src/juce_core/text/juce_String.cpp index ab8dfda205..5b30fabd92 100644 --- a/src/juce_core/text/juce_String.cpp +++ b/src/juce_core/text/juce_String.cpp @@ -50,7 +50,7 @@ BEGIN_JUCE_NAMESPACE #endif //============================================================================== -static const tchar* const emptyCharString = T("\0\0\0\0JUCE"); +static const char* const emptyCharString = "\0\0\0\0JUCE"; static const int safeEmptyStringRefCount = 0x3fffffff; String::InternalRefCountedStringHolder String::emptyString = { safeEmptyStringRefCount, 0, { 0 } }; @@ -72,6 +72,15 @@ void String::createInternal (const int numChars) throw() text->text[0] = 0; } +void String::createInternal (const tchar* const t, const tchar* const textEnd) throw() +{ + jassert (*(textEnd - 1) == 0); // must have a null terminator + + const int numChars = (int) (textEnd - t); + createInternal (numChars - 1); + memcpy (text->text, t, numChars * sizeof (tchar)); +} + void String::appendInternal (const tchar* const newText, const int numExtraChars) throw() { @@ -322,55 +331,40 @@ String::String (const int number) throw() { tchar buffer [16]; tchar* const end = buffer + 16; - const tchar* const t = intToCharString (end, number); - const int numChars = (int) (end - t); - createInternal (numChars - 1); - memcpy (text->text, t, numChars * sizeof (tchar)); + createInternal (intToCharString (end, number), end); } String::String (const unsigned int number) throw() { tchar buffer [16]; tchar* const end = buffer + 16; - const tchar* const t = uintToCharString (end, number); - const int numChars = (int) (end - t); - createInternal (numChars - 1); - memcpy (text->text, t, numChars * sizeof (tchar)); + createInternal (uintToCharString (end, number), end); } String::String (const short number) throw() { tchar buffer [16]; tchar* const end = buffer + 16; - const tchar* const t = intToCharString (end, (int) number); - const int numChars = (int) (end - t); - createInternal (numChars - 1); - memcpy (text->text, t, numChars * sizeof (tchar)); + createInternal (intToCharString (end, (int) number), end); } String::String (const unsigned short number) throw() { tchar buffer [16]; tchar* const end = buffer + 16; - const tchar* const t = uintToCharString (end, (unsigned int) number); - const int numChars = (int) (end - t); - createInternal (numChars - 1); - memcpy (text->text, t, numChars * sizeof (tchar)); + createInternal (uintToCharString (end, (unsigned int) number), end); } String::String (const int64 number) throw() { tchar buffer [32]; tchar* const end = buffer + 32; - const tchar* const t = int64ToCharString (end, number); - const int numChars = (int) (end - t); - createInternal (numChars - 1); - memcpy (text->text, t, numChars * sizeof (tchar)); + createInternal (int64ToCharString (end, number), end); } String::String (const uint64 number) throw() @@ -389,9 +383,7 @@ String::String (const uint64 number) throw() } while (v > 0); - const int numChars = (int) (end - t); - createInternal (numChars - 1); - memcpy (text->text, t, numChars * sizeof (tchar)); + createInternal (t, end); } // a double-to-string routine that actually uses the number of dec. places you asked for diff --git a/src/juce_core/text/juce_String.h b/src/juce_core/text/juce_String.h index 87c15e9931..fcfd830914 100644 --- a/src/juce_core/text/juce_String.h +++ b/src/juce_core/text/juce_String.h @@ -1043,6 +1043,7 @@ private: void deleteInternal() throw(); void createInternal (const int numChars) throw(); + void createInternal (const tchar* const text, const tchar* const textEnd) throw(); void appendInternal (const tchar* const text, const int numExtraChars) throw(); void doubleToStringWithDecPlaces (double n, int numDecPlaces) throw(); void dupeInternalIfMultiplyReferenced() throw(); diff --git a/src/juce_core/threads/juce_InterProcessLock.h b/src/juce_core/threads/juce_InterProcessLock.h index 325b28f73f..24fa3ca891 100644 --- a/src/juce_core/threads/juce_InterProcessLock.h +++ b/src/juce_core/threads/juce_InterProcessLock.h @@ -49,13 +49,13 @@ public: @param name a name that processes will use to identify this lock object */ - InterProcessLock (const String& name); + InterProcessLock (const String& name) throw(); /** Destructor. This will also release the lock if it's currently held by this process. */ - ~InterProcessLock(); + ~InterProcessLock() throw(); //============================================================================== /** Attempts to lock the critical section. @@ -67,11 +67,11 @@ public: @returns true if the lock could be gained within the timeout period, or false if the timeout expired. */ - bool enter (int timeOutMillisecs = -1); + bool enter (int timeOutMillisecs = -1) throw(); /** Releases the lock if it's currently held by this process. */ - void exit(); + void exit() throw(); //==============================================================================