Browse Source

A handful of small fixes and whitespace clean-ups. Added a parameter to the DatagramSocket::read to specify whether the operation should block.

tags/2021-05-28
jules 17 years ago
parent
commit
787a4e6de9
17 changed files with 1490 additions and 1469 deletions
  1. +1
    -1
      build/linux/platform_specific_code/juce_linux_Files.cpp
  2. +5
    -3
      build/macosx/platform_specific_code/juce_mac_NSViewComponentPeer.mm
  3. +2
    -2
      build/macosx/platform_specific_code/juce_mac_Network.mm
  4. +2
    -2
      build/macosx/platform_specific_code/juce_posix_SharedCode.h
  5. +1
    -1
      build/win32/platform_specific_code/juce_win32_Windowing.cpp
  6. +2
    -2
      extras/juce demo/src/binarydata/WidgetsDemo.cpp
  7. +1435
    -1435
      extras/juce demo/src/demos/WidgetsDemo.cpp
  8. +1
    -1
      src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp
  9. +7
    -0
      src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.h
  10. +2
    -2
      src/juce_appframework/events/juce_InterprocessConnection.cpp
  11. +1
    -1
      src/juce_appframework/gui/components/controls/juce_ProgressBar.cpp
  12. +1
    -1
      src/juce_appframework/gui/components/controls/juce_TreeView.cpp
  13. +1
    -1
      src/juce_appframework/gui/components/windows/juce_ComponentPeer.cpp
  14. +1
    -1
      src/juce_appframework/gui/components/windows/juce_ThreadWithProgressWindow.cpp
  15. +3
    -3
      src/juce_appframework/gui/components/windows/juce_TooltipWindow.cpp
  16. +9
    -5
      src/juce_core/io/network/juce_Socket.cpp
  17. +16
    -8
      src/juce_core/io/network/juce_Socket.h

+ 1
- 1
build/linux/platform_specific_code/juce_linux_Files.cpp View File

@@ -55,7 +55,7 @@ BEGIN_JUCE_NAMESPACE
#include "../../../src/juce_core/io/files/juce_FileOutputStream.h"
#include "../../../src/juce_core/basics/juce_SystemStats.h"
#include "../../../src/juce_core/basics/juce_Time.h"
#include "../../../src/juce_core/basics/juce_Random.h"
#include "../../../src/juce_core/basics/juce_Random.h"
#include "../../../src/juce_core/io/network/juce_URL.h"
#include "../../../src/juce_core/io/files/juce_NamedPipe.h"
#include "../../../src/juce_core/threads/juce_InterProcessLock.h"


+ 5
- 3
build/macosx/platform_specific_code/juce_mac_NSViewComponentPeer.mm View File

@@ -181,7 +181,7 @@ public:
virtual NSRect constrainRect (NSRect r);
static void showArrowCursorIfNeeded();
//==============================================================================
virtual void viewFocusGain();
virtual void viewFocusLoss();
@@ -636,7 +636,9 @@ static int getKeyCodeFromEvent (NSEvent* ev)
int keyCode = unmodified[0];
if (keyCode == 0x19) // (backwards-tab)
keyCode = 9;
keyCode = '\t';
else if (keyCode == 0x03) // (enter)
keyCode = '\r';
return keyCode;
}
@@ -1296,7 +1298,7 @@ void NSViewComponentPeer::showArrowCursorIfNeeded()
{
int mx, my;
Desktop::getInstance().getMousePosition (mx, my);
if (Desktop::getInstance().findComponentAt (mx, my) == 0)
[[NSCursor arrowCursor] set];
}


+ 2
- 2
build/macosx/platform_specific_code/juce_mac_Network.mm View File

@@ -203,7 +203,6 @@ public:
: Thread (T("http connection")),
owner (owner_)
{
startThread();
}
~JuceURLConnectionMessageThread()
@@ -241,6 +240,7 @@ public:
hasFinished = false;
runLoopThread = new JuceURLConnectionMessageThread (self);
runLoopThread->startThread();
while (runLoopThread->isThreadRunning() && ! initialised)
{
@@ -268,7 +268,7 @@ public:
- (void) createConnection
{
connection = [[NSURLConnection alloc] initWithRequest: request
delegate: self];
delegate: [self retain]];
if (connection == nil)
runLoopThread->signalThreadShouldExit();


+ 2
- 2
build/macosx/platform_specific_code/juce_posix_SharedCode.h View File

@@ -402,9 +402,9 @@ const String juce_getOutputFromCommand (const String& command)
// slight bodge here, as we just pipe the output into a temp file and read it...
const File tempFile (File::getSpecialLocation (File::tempDirectory)
.getNonexistentChildFile (String::toHexString (Random::getSystemRandom().nextInt()), ".tmp", false));
juce_runSystemCommand (command + " > " + tempFile.getFullPathName());
String result (tempFile.loadFileAsString());
tempFile.deleteFile();
return result;


+ 1
- 1
build/win32/platform_specific_code/juce_win32_Windowing.cpp View File

@@ -434,7 +434,7 @@ static void* callFunctionIfNotLocked (MessageCallbackFunction* callback, void* u
if (MessageManager::getInstance()->currentThreadHasLockedMessageManager())
return callback (userData);
else
MessageManager::getInstance()->callFunctionOnMessageThread (callback, userData);
return MessageManager::getInstance()->callFunctionOnMessageThread (callback, userData);
}
//==============================================================================


+ 2
- 2
extras/juce demo/src/binarydata/WidgetsDemo.cpp View File

@@ -990,7 +990,7 @@ public:
// must check this as often as possible, because this is
// how we know if the user's pressed 'cancel'
if (threadShouldExit())
break;
return;
// this will update the progress bar on the dialog box
setProgress (i / (double) thingsToDo);
@@ -1002,7 +1002,7 @@ public:
setProgress (-1.0); // setting a value beyond the range 0 -> 1 will show a spinning bar..
setStatusMessage (T("Finishing off the last few bits and pieces!"));
wait (3000);
wait (2000);
}
};


+ 1435
- 1435
extras/juce demo/src/demos/WidgetsDemo.cpp
File diff suppressed because it is too large
View File


+ 1
- 1
src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp View File

@@ -164,7 +164,7 @@ const AudioSampleBuffer& AudioSampleBuffer::operator= (const AudioSampleBuffer&
AudioSampleBuffer::~AudioSampleBuffer() throw()
{
juce_free (allocatedData);
if (channels != (float**) preallocatedChannelSpace)
juce_free (channels);
}


+ 7
- 0
src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.h View File

@@ -116,6 +116,13 @@ public:
float* getSampleData (const int channelNumber,
const int sampleOffset = 0) const throw();
/** Returns an array of pointers to the channels in the buffer.
Don't modify any of the pointers that are returned, and bear in mind that
these will become invalid if the buffer is resized.
*/
float** getArrayOfChannels() const throw() { return channels; }
//==============================================================================
/** Chages the buffer's size or number of channels.


+ 2
- 2
src/juce_appframework/events/juce_InterprocessConnection.cpp View File

@@ -289,7 +289,7 @@ bool InterprocessConnection::readNextMessageInt()
const int maximumMessageSize = 1024 * 1024 * 10; // sanity check
uint32 messageHeader[2];
const int bytes = (socket != 0) ? socket->read (messageHeader, sizeof (messageHeader))
const int bytes = (socket != 0) ? socket->read (messageHeader, sizeof (messageHeader), true)
: pipe->read (messageHeader, sizeof (messageHeader), pipeReceiveMessageTimeout);
if (bytes == sizeof (messageHeader)
@@ -308,7 +308,7 @@ bool InterprocessConnection::readNextMessageInt()
return false;
const int numThisTime = jmin (bytesInMessage, 65536);
const int bytesIn = (socket != 0) ? socket->read (((char*) messageData.getData()) + bytesRead, numThisTime)
const int bytesIn = (socket != 0) ? socket->read (((char*) messageData.getData()) + bytesRead, numThisTime, true)
: pipe->read (((char*) messageData.getData()) + bytesRead, numThisTime,
pipeReceiveMessageTimeout);


+ 1
- 1
src/juce_appframework/gui/components/controls/juce_ProgressBar.cpp View File

@@ -116,7 +116,7 @@ void ProgressBar::timerCallback()
const int timeSinceLastCallback = (int) (now - lastCallbackTime);
lastCallbackTime = now;
newProgress = jmin (currentValue + 0.00018 * timeSinceLastCallback,
newProgress = jmin (currentValue + 0.00018 * timeSinceLastCallback,
newProgress);
}


+ 1
- 1
src/juce_appframework/gui/components/controls/juce_TreeView.cpp View File

@@ -314,7 +314,7 @@ public:
if (item != 0)
return item->getTooltip();
return owner->getTooltip();
}


+ 1
- 1
src/juce_appframework/gui/components/windows/juce_ComponentPeer.cpp View File

@@ -466,7 +466,7 @@ bool ComponentPeer::handleKeyPress (const int keyCode,
keyWasUsed = (currentlyFocused != Component::getCurrentlyFocusedComponent());
break;
}
target = target->parentComponent_;
}


+ 1
- 1
src/juce_appframework/gui/components/windows/juce_ThreadWithProgressWindow.cpp View File

@@ -50,7 +50,7 @@ ThreadWithProgressWindow::ThreadWithProgressWindow (const String& title,
timeOutMsWhenCancelling (timeOutMsWhenCancelling_)
{
alertWindow = LookAndFeel::getDefaultLookAndFeel()
.createAlertWindow (title, String::empty, cancelButtonText,
.createAlertWindow (title, String::empty, cancelButtonText,
String::empty, String::empty,
AlertWindow::NoIcon, hasCancelButton ? 1 : 0, 0);


+ 3
- 3
src/juce_appframework/gui/components/windows/juce_TooltipWindow.cpp View File

@@ -80,7 +80,7 @@ void TooltipWindow::showFor (Component* const c, const String& tip)
{
jassert (tip.isNotEmpty());
tipShowing = tip;
int mx, my;
Desktop::getMousePosition (mx, my);
@@ -158,7 +158,7 @@ void TooltipWindow::timerCallback()
if (isVisible() || now < lastHideTime + 500)
{
// if a tip is currently visible (or has just disappeared), update to a new one
// immediately if needed..
// immediately if needed..
if (newComp == 0 || mouseWasClicked || newTip.isEmpty())
{
if (isVisible())
@@ -174,7 +174,7 @@ void TooltipWindow::timerCallback()
}
else
{
// if there isn't currently a tip, but one is needed, only let it
// if there isn't currently a tip, but one is needed, only let it
// appear after a timeout..
if (newTip.isNotEmpty()
&& newTip != tipShowing


+ 9
- 5
src/juce_core/io/network/juce_Socket.cpp View File

@@ -118,7 +118,8 @@ static bool bindSocketToPort (const int handle, const int port) throw()
static int readSocket (const int handle,
void* const destBuffer, const int maxBytesToRead,
bool volatile& connected) throw()
bool volatile& connected,
const bool blockUntilSpecifiedAmountHasArrived) throw()
{
int bytesRead = 0;
@@ -145,6 +146,9 @@ static int readSocket (const int handle,
}
bytesRead += bytesThisTime;
if (! blockUntilSpecifiedAmountHasArrived)
break;
}
return bytesRead;
@@ -335,9 +339,9 @@ StreamingSocket::~StreamingSocket()
}
//==============================================================================
int StreamingSocket::read (void* destBuffer, const int maxBytesToRead)
int StreamingSocket::read (void* destBuffer, const int maxBytesToRead, const bool blockUntilSpecifiedAmountHasArrived)
{
return (connected && ! isListener) ? readSocket (handle, destBuffer, maxBytesToRead, connected)
return (connected && ! isListener) ? readSocket (handle, destBuffer, maxBytesToRead, connected, blockUntilSpecifiedAmountHasArrived)
: -1;
}
@@ -611,9 +615,9 @@ int DatagramSocket::waitUntilReady (const bool readyForReading,
: -1;
}
int DatagramSocket::read (void* destBuffer, const int maxBytesToRead)
int DatagramSocket::read (void* destBuffer, const int maxBytesToRead, const bool blockUntilSpecifiedAmountHasArrived)
{
return connected ? readSocket (handle, destBuffer, maxBytesToRead, connected)
return connected ? readSocket (handle, destBuffer, maxBytesToRead, connected, blockUntilSpecifiedAmountHasArrived)
: -1;
}


+ 16
- 8
src/juce_core/io/network/juce_Socket.h View File

@@ -112,14 +112,18 @@ public:
int waitUntilReady (const bool readyForReading,
const int timeoutMsecs) const;
/** Reads bytes from the socket (blocking).
/** Reads bytes from the socket.
Note that this method will block unless you have checked the socket is ready
for reading before calling it (see the waitUntilReady() method).
If blockUntilSpecifiedAmountHasArrived is true, the method will block until
maxBytesToRead bytes have been read, (or until an error occurs). If this
flag is false, the method will return as much data as is currently available
without blocking.
@returns the number of bytes read, or -1 if there was an error.
@see waitUntilReady
*/
int read (void* destBuffer, const int maxBytesToRead);
int read (void* destBuffer, const int maxBytesToRead,
const bool blockUntilSpecifiedAmountHasArrived);
/** Writes bytes to the socket from a buffer.
@@ -249,14 +253,18 @@ public:
int waitUntilReady (const bool readyForReading,
const int timeoutMsecs) const;
/** Reads bytes from the socket (blocking).
/** Reads bytes from the socket.
Note that this method will block unless you have checked the socket is ready
for reading before calling it (see the waitUntilReady() method).
If blockUntilSpecifiedAmountHasArrived is true, the method will block until
maxBytesToRead bytes have been read, (or until an error occurs). If this
flag is false, the method will return as much data as is currently available
without blocking.
@returns the number of bytes read, or -1 if there was an error.
@see waitUntilReady
*/
int read (void* destBuffer, const int maxBytesToRead);
int read (void* destBuffer, const int maxBytesToRead,
const bool blockUntilSpecifiedAmountHasArrived);
/** Writes bytes to the socket from a buffer.


Loading…
Cancel
Save