From cc45ec88f5b9c56d18081707ee191b476b44ff68 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Wed, 9 Jun 2010 20:11:43 +0100 Subject: [PATCH] Misc fixes and tweaks for networking, pthreads, jucer project generation, drawables. --- .../Drawable/jucer_DrawableTypeHandler.cpp | 87 ++++++++++++++++++- .../model/Project/jucer_ProjectExport_XCode.h | 7 +- .../ui/Editor Base/jucer_EditorCanvas.cpp | 2 +- .../Source/utility/jucer_MiscUtilities.cpp | 9 +- juce_amalgamated.cpp | 73 ++++++++++------ juce_amalgamated.h | 6 +- src/core/juce_StandardHeader.h | 2 +- .../components/controls/juce_TextEditor.cpp | 21 +++-- .../graphics/drawables/juce_DrawableText.cpp | 11 +-- .../graphics/drawables/juce_DrawableText.h | 4 +- src/io/network/juce_URL.cpp | 3 + src/native/common/juce_posix_SharedCode.h | 6 +- src/native/linux/juce_linux_Messaging.cpp | 3 +- src/native/linux/juce_linux_Network.cpp | 6 +- src/native/mac/juce_mac_Network.mm | 6 +- src/native/windows/juce_win32_Network.cpp | 12 +-- 16 files changed, 190 insertions(+), 68 deletions(-) diff --git a/extras/Jucer (experimental)/Source/model/Drawable/jucer_DrawableTypeHandler.cpp b/extras/Jucer (experimental)/Source/model/Drawable/jucer_DrawableTypeHandler.cpp index a374700407..e79fb5ec01 100644 --- a/extras/Jucer (experimental)/Source/model/Drawable/jucer_DrawableTypeHandler.cpp +++ b/extras/Jucer (experimental)/Source/model/Drawable/jucer_DrawableTypeHandler.cpp @@ -861,6 +861,10 @@ public: Value v (wrapper.getFontValue (item.getUndoManager())); props.add (FontNameValueSource::createProperty ("Font", v)); props.add (FontStyleValueSource::createProperty ("Font Style", v)); + + props.add (new SliderPropertyComponent (Value (new FontDimensionSource (item, true)), "Font Height", 1.0, 150.0, 0.1, 0.5)); + props.add (new SliderPropertyComponent (Value (new FontDimensionSource (item, false)), "Font Scale", 0.05, 10.0, 0.01, 0.5)); + props.add (new ResetButtonPropertyComponent (item, wrapper)); } @@ -888,7 +892,7 @@ public: case 0: return wrapper.getBoundingBox().topLeft; case 1: return wrapper.getBoundingBox().topRight; case 2: return wrapper.getBoundingBox().bottomLeft; - case 3: return wrapper.getFontSizeAndScaleAnchor(); + case 3: return wrapper.getFontSizeControlPoint(); default: jassertfalse; break; } @@ -901,7 +905,7 @@ public: if (cpNum == 3) { - wrapper.setFontSizeAndScaleAnchor (newPoint, undoManager); + wrapper.setFontSizeControlPoint (newPoint, undoManager); } else { @@ -981,17 +985,92 @@ public: const AffineTransform t (bounds.resetToPerpendicular (&item)); - RelativePoint fontPos (wrapper.getFontSizeAndScaleAnchor()); + RelativePoint fontPos (wrapper.getFontSizeControlPoint()); fontPos.moveToAbsolute (fontPos.resolve (&item).transformedBy (t), &item); wrapper.setBoundingBox (bounds, item.getUndoManager()); - wrapper.setFontSizeAndScaleAnchor (fontPos, item.getUndoManager()); + wrapper.setFontSizeControlPoint (fontPos, item.getUndoManager()); } private: DrawableTypeInstance item; DrawableText::ValueTreeWrapper wrapper; }; + + //============================================================================== + class FontDimensionSource : public Value::ValueSource, + public ValueTree::Listener + { + public: + FontDimensionSource (const DrawableTypeInstance& item_, bool isHeight_) + : item (item_), isHeight (isHeight_), reentrant (false) + { + item.getState().addListener (this); + } + + ~FontDimensionSource() {} + + const var getValue() const + { + DrawableText::ValueTreeWrapper wrapper (item.getState()); + + const RelativeParallelogram bounds (wrapper.getBoundingBox()); + RelativePoint fontPoint (wrapper.getFontSizeControlPoint()); + + Point corners[3]; + bounds.resolveThreePoints (corners, &item); + + Point sizeAndScale (RelativeParallelogram::getInternalCoordForPoint (corners, fontPoint.resolve (&item))); + + if (isHeight) + return sizeAndScale.getY(); + else + return sizeAndScale.getX() / sizeAndScale.getY(); + } + + void setValue (const var& newValue) + { + if (reentrant) + return; + + DrawableText::ValueTreeWrapper wrapper (item.getState()); + + const RelativeParallelogram bounds (wrapper.getBoundingBox()); + RelativePoint fontPoint (wrapper.getFontSizeControlPoint()); + + Point corners[3]; + bounds.resolveThreePoints (corners, &item); + + Point sizeAndScale (RelativeParallelogram::getInternalCoordForPoint (corners, fontPoint.resolve (&item))); + const Point oldSize (sizeAndScale); + + if (isHeight) + sizeAndScale.setXY ((oldSize.getX() / oldSize.getY()) * (float) newValue, (float) newValue); + else + sizeAndScale.setX (sizeAndScale.getY() * (float) newValue); + + if (oldSize.getDistanceFrom (sizeAndScale) > 0.001f) + wrapper.setFontSizeControlPoint (RelativePoint (RelativeParallelogram::getPointForInternalCoord (corners, sizeAndScale)), + item.getUndoManager()); + } + + void valueTreePropertyChanged (ValueTree& tree, const Identifier& property) + { + reentrant = true; + sendChangeMessage (true); + reentrant = false; + } + + void valueTreeChildrenChanged (ValueTree& tree) {} + void valueTreeParentChanged (ValueTree& tree) {} + + protected: + mutable DrawableTypeInstance item; + bool isHeight, reentrant; + + FontDimensionSource (const FontDimensionSource&); + const FontDimensionSource& operator= (const FontDimensionSource&); + }; }; diff --git a/extras/Jucer (experimental)/Source/model/Project/jucer_ProjectExport_XCode.h b/extras/Jucer (experimental)/Source/model/Project/jucer_ProjectExport_XCode.h index 87aac84f21..4b872c8e1f 100644 --- a/extras/Jucer (experimental)/Source/model/Project/jucer_ProjectExport_XCode.h +++ b/extras/Jucer (experimental)/Source/model/Project/jucer_ProjectExport_XCode.h @@ -148,7 +148,6 @@ private: } const File getProjectBundle() const { return getTargetFolder().getChildFile (project.getProjectFilenameRoot()).withFileExtension (".xcodeproj"); } - const RelativePath getJuceLibFile() const { return getJucePathFromTargetFolder().getChildFile ("bin/libjucedebug.a"); } bool hasPList() const { return ! (project.isLibrary() || project.isCommandLineApp()); } const String getAudioPluginBundleExtension() const { return "component"; } @@ -359,7 +358,11 @@ private: } if (project.getJuceLinkageMode() == Project::useLinkedJuce) - getLinkerFlagsForStaticLibrary (getJuceLibFile(), flags, librarySearchPaths); + { + RelativePath juceLib (getJucePathFromTargetFolder().getChildFile (config.isDebug().getValue() ? "bin/libjucedebug.a" + : "bin/libjuce.a")); + getLinkerFlagsForStaticLibrary (juceLib, flags, librarySearchPaths); + } flags.add (getExtraLinkerFlags().toString()); flags.removeEmptyStrings (true); diff --git a/extras/Jucer (experimental)/Source/ui/Editor Base/jucer_EditorCanvas.cpp b/extras/Jucer (experimental)/Source/ui/Editor Base/jucer_EditorCanvas.cpp index 15424acb55..c2ce593e7d 100644 --- a/extras/Jucer (experimental)/Source/ui/Editor Base/jucer_EditorCanvas.cpp +++ b/extras/Jucer (experimental)/Source/ui/Editor Base/jucer_EditorCanvas.cpp @@ -189,7 +189,7 @@ public: } setBoundsInTargetSpace (r); - label.update (getParentComponent(), coord.toString(), resizableBorderColour.withAlpha (0.9f), getX(), getY(), type != left, type != top); + label.update (getParentComponent(), coord.toString(), Colours::darkgrey, getX(), getY(), type != left, type != top); } private: diff --git a/extras/Jucer (experimental)/Source/utility/jucer_MiscUtilities.cpp b/extras/Jucer (experimental)/Source/utility/jucer_MiscUtilities.cpp index 4fb15c2c33..06c7a75d02 100644 --- a/extras/Jucer (experimental)/Source/utility/jucer_MiscUtilities.cpp +++ b/extras/Jucer (experimental)/Source/utility/jucer_MiscUtilities.cpp @@ -220,7 +220,7 @@ const String PropertyPanelWithTooltips::findTip (Component* c) FloatingLabelComponent::FloatingLabelComponent() : font (10.0f) { - setInterceptsMouseClicks (false ,false); + setInterceptsMouseClicks (false, false); } void FloatingLabelComponent::remove() @@ -243,7 +243,7 @@ void FloatingLabelComponent::update (Component* parent, const String& text, cons glyphs.justifyGlyphs (0, std::numeric_limits::max(), 0, 0, 1000, 1000, Justification::topLeft); r = glyphs.getBoundingBox (0, std::numeric_limits::max(), false) - .getSmallestIntegerContainer().expanded (2, 2); + .getSmallestIntegerContainer().expanded (1, 1); } else { @@ -259,10 +259,7 @@ void FloatingLabelComponent::paint (Graphics& g) { g.setFont (font); g.setColour (Colours::white.withAlpha (0.5f)); - - for (int y = -1; y <= 1; ++y) - for (int x = -1; x <= 1; ++x) - glyphs.draw (g, AffineTransform::translation (1.0f + x, 1.0f + y)); + g.fillRoundedRectangle (0, 0, (float) getWidth(), (float) getHeight(), 3); g.setColour (colour); glyphs.draw (g, AffineTransform::translation (1.0f, 1.0f)); diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 854b175079..7d4daddf15 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -8280,12 +8280,15 @@ private: } data << "--\r\n"; + data.flush(); } else { data << getMangledParameters (url.getParameters()) << url.getPostData(); + data.flush(); + // just a short text attachment, so use simple url encoding.. headers = "Content-Type: application/x-www-form-urlencoded\r\nContent-length: " + String ((unsigned int) postData.getSize()) @@ -51921,8 +51924,7 @@ class TextEditorViewport : public Viewport { public: TextEditorViewport (TextEditor* const owner_) - : owner (owner_), - lastWordWrapWidth (0) + : owner (owner_), lastWordWrapWidth (0), rentrant (false) { } @@ -51932,18 +51934,26 @@ public: void visibleAreaChanged (int, int, int, int) { - const float wordWrapWidth = owner->getWordWrapWidth(); - - if (wordWrapWidth != lastWordWrapWidth) + if (! rentrant) // it's rare, but possible to get into a feedback loop as the viewport's scrollbars + // appear and disappear, causing the wrap width to change. { - lastWordWrapWidth = wordWrapWidth; - owner->updateTextHolderSize(); + const float wordWrapWidth = owner->getWordWrapWidth(); + + if (wordWrapWidth != lastWordWrapWidth) + { + lastWordWrapWidth = wordWrapWidth; + + rentrant = true; + owner->updateTextHolderSize(); + rentrant = false; + } } } private: TextEditor* const owner; float lastWordWrapWidth; + bool rentrant; TextEditorViewport (const TextEditorViewport&); TextEditorViewport& operator= (const TextEditorViewport&); @@ -85569,7 +85579,7 @@ void DrawableText::setFont (const Font& newFont, bool applySizeAndScale) Point corners[3]; bounds.resolveThreePoints (corners, parent); - setFontSizeControlPoint (RelativePoint (bounds.getPointForInternalCoord (corners, + setFontSizeControlPoint (RelativePoint (RelativeParallelogram::getPointForInternalCoord (corners, Point (font.getHorizontalScale() * font.getHeight(), font.getHeight())))); } } @@ -85716,12 +85726,12 @@ void DrawableText::ValueTreeWrapper::setBoundingBox (const RelativeParallelogram state.setProperty (bottomLeft, newBounds.bottomLeft.toString(), undoManager); } -const RelativePoint DrawableText::ValueTreeWrapper::getFontSizeAndScaleAnchor() const +const RelativePoint DrawableText::ValueTreeWrapper::getFontSizeControlPoint() const { return state [fontSizeAnchor].toString(); } -void DrawableText::ValueTreeWrapper::setFontSizeAndScaleAnchor (const RelativePoint& p, UndoManager* undoManager) +void DrawableText::ValueTreeWrapper::setFontSizeControlPoint (const RelativePoint& p, UndoManager* undoManager) { state.setProperty (fontSizeAnchor, p.toString(), undoManager); } @@ -85732,7 +85742,7 @@ const Rectangle DrawableText::refreshFromValueTree (const ValueTree& tree setName (v.getID()); const RelativeParallelogram newBounds (v.getBoundingBox()); - const RelativePoint newFontPoint (v.getFontSizeAndScaleAnchor()); + const RelativePoint newFontPoint (v.getFontSizeControlPoint()); const Colour newColour (v.getColour()); const Justification newJustification (v.getJustification()); const String newText (v.getText()); @@ -85768,7 +85778,7 @@ const ValueTree DrawableText::createValueTree (ImageProvider*) const v.setJustification (justification, 0); v.setColour (colour, 0); v.setBoundingBox (bounds, 0); - v.setFontSizeAndScaleAnchor (fontSizeControlPoint, 0); + v.setFontSizeControlPoint (fontSizeControlPoint, 0); return tree; } @@ -237916,7 +237926,7 @@ void* juce_openInternetFile (const String& url, { const TCHAR* mimeTypes[] = { _T("*/*"), 0 }; - DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE; + DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES; if (url.startsWithIgnoreCase ("https:")) flags |= INTERNET_FLAG_SECURE; // (this flag only seems necessary if the OS is running IE6 - @@ -237961,7 +237971,9 @@ void* juce_openInternetFile (const String& url, result->connection = connection; result->request = request; - HttpEndRequest (request, 0, 0, 0); + if (! HttpEndRequest (request, 0, 0, 0)) + break; + return result; } @@ -238043,11 +238055,11 @@ void juce_getInternetFileHeaders (void* handle, StringPairArray& headers) for (int i = 0; i < headersArray.size(); ++i) { const String& header = headersArray[i]; - const String key (header.upToFirstOccurrenceOf (": ", false, false)); - const String value (header.fromFirstOccurrenceOf (": ", false, false)); + const String key (header.upToFirstOccurrenceOf ("; ", false, false)); + const String value (header.fromFirstOccurrenceOf ("; ", false, false)); const String previousValue (headers [key]); - headers.set (key, previousValue.isEmpty() ? value : (previousValue + ";" + value)); + headers.set (key, previousValue.isEmpty() ? value : (previousValue + "," + value)); } break; @@ -252387,7 +252399,11 @@ public: manualReset (manualReset_) { pthread_cond_init (&condition, 0); - pthread_mutex_init (&mutex, 0); + + pthread_mutexattr_t atts; + pthread_mutexattr_init (&atts); + pthread_mutexattr_setprotocol (&atts, PTHREAD_PRIO_INHERIT); + pthread_mutex_init (&mutex, &atts); } ~WaitableEventImpl() @@ -253858,10 +253874,10 @@ void juce_getInternetFileHeaders (void* handle, StringPairArray& headers) for (int i = 0; i < s->headerLines.size(); ++i) { const String& headersEntry = s->headerLines[i]; - const String key (headersEntry.upToFirstOccurrenceOf (": ", false, false)); - const String value (headersEntry.fromFirstOccurrenceOf (": ", false, false)); + const String key (headersEntry.upToFirstOccurrenceOf ("; ", false, false)); + const String value (headersEntry.fromFirstOccurrenceOf ("; ", false, false)); const String previousValue (headers [key]); - headers.set (key, previousValue.isEmpty() ? value : (previousValue + ";" + value)); + headers.set (key, previousValue.isEmpty() ? value : (previousValue + "," + value)); } } } @@ -254730,11 +254746,10 @@ namespace LinuxErrorHandling static int ioErrorHandler (Display* display) { DBG ("ERROR: connection to X server broken.. terminating."); - errorOccurred = true; if (JUCEApplication::getInstance() != 0) - Process::terminate(); + MessageManager::getInstance()->stopDispatchLoop(); return 0; } @@ -261723,8 +261738,12 @@ public: - (void) createConnection { + NSInteger oldRetainCount = [self retainCount]; connection = [[NSURLConnection alloc] initWithRequest: request - delegate: [self retain]]; + delegate: self]; + + if (oldRetainCount == [self retainCount]) + [self retain]; // newer SDK should already retain this, but there were problems in older versions.. if (connection == nil) runLoopThread->signalThreadShouldExit(); @@ -262282,7 +262301,11 @@ public: manualReset (manualReset_) { pthread_cond_init (&condition, 0); - pthread_mutex_init (&mutex, 0); + + pthread_mutexattr_t atts; + pthread_mutexattr_init (&atts); + pthread_mutexattr_setprotocol (&atts, PTHREAD_PRIO_INHERIT); + pthread_mutex_init (&mutex, &atts); } ~WaitableEventImpl() diff --git a/juce_amalgamated.h b/juce_amalgamated.h index bbe455c0d4..793351893b 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -64,7 +64,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 52 -#define JUCE_BUILDNUMBER 14 +#define JUCE_BUILDNUMBER 15 /** Current Juce version number. @@ -59161,8 +59161,8 @@ public: const RelativeParallelogram getBoundingBox() const; void setBoundingBox (const RelativeParallelogram& newBounds, UndoManager* undoManager); - const RelativePoint getFontSizeAndScaleAnchor() const; - void setFontSizeAndScaleAnchor (const RelativePoint& p, UndoManager* undoManager); + const RelativePoint getFontSizeControlPoint() const; + void setFontSizeControlPoint (const RelativePoint& p, UndoManager* undoManager); static const Identifier text, colour, font, justification, topLeft, topRight, bottomLeft, fontSizeAnchor; }; diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index a4593de283..39ba9ea306 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 52 -#define JUCE_BUILDNUMBER 14 +#define JUCE_BUILDNUMBER 15 /** Current Juce version number. diff --git a/src/gui/components/controls/juce_TextEditor.cpp b/src/gui/components/controls/juce_TextEditor.cpp index 6cbd9a8ccf..8a12261cfe 100644 --- a/src/gui/components/controls/juce_TextEditor.cpp +++ b/src/gui/components/controls/juce_TextEditor.cpp @@ -919,8 +919,7 @@ class TextEditorViewport : public Viewport { public: TextEditorViewport (TextEditor* const owner_) - : owner (owner_), - lastWordWrapWidth (0) + : owner (owner_), lastWordWrapWidth (0), rentrant (false) { } @@ -930,18 +929,26 @@ public: void visibleAreaChanged (int, int, int, int) { - const float wordWrapWidth = owner->getWordWrapWidth(); - - if (wordWrapWidth != lastWordWrapWidth) + if (! rentrant) // it's rare, but possible to get into a feedback loop as the viewport's scrollbars + // appear and disappear, causing the wrap width to change. { - lastWordWrapWidth = wordWrapWidth; - owner->updateTextHolderSize(); + const float wordWrapWidth = owner->getWordWrapWidth(); + + if (wordWrapWidth != lastWordWrapWidth) + { + lastWordWrapWidth = wordWrapWidth; + + rentrant = true; + owner->updateTextHolderSize(); + rentrant = false; + } } } private: TextEditor* const owner; float lastWordWrapWidth; + bool rentrant; TextEditorViewport (const TextEditorViewport&); TextEditorViewport& operator= (const TextEditorViewport&); diff --git a/src/gui/graphics/drawables/juce_DrawableText.cpp b/src/gui/graphics/drawables/juce_DrawableText.cpp index a74536b272..71a2be889b 100644 --- a/src/gui/graphics/drawables/juce_DrawableText.cpp +++ b/src/gui/graphics/drawables/juce_DrawableText.cpp @@ -73,7 +73,7 @@ void DrawableText::setFont (const Font& newFont, bool applySizeAndScale) Point corners[3]; bounds.resolveThreePoints (corners, parent); - setFontSizeControlPoint (RelativePoint (bounds.getPointForInternalCoord (corners, + setFontSizeControlPoint (RelativePoint (RelativeParallelogram::getPointForInternalCoord (corners, Point (font.getHorizontalScale() * font.getHeight(), font.getHeight())))); } } @@ -223,23 +223,24 @@ void DrawableText::ValueTreeWrapper::setBoundingBox (const RelativeParallelogram state.setProperty (bottomLeft, newBounds.bottomLeft.toString(), undoManager); } -const RelativePoint DrawableText::ValueTreeWrapper::getFontSizeAndScaleAnchor() const +const RelativePoint DrawableText::ValueTreeWrapper::getFontSizeControlPoint() const { return state [fontSizeAnchor].toString(); } -void DrawableText::ValueTreeWrapper::setFontSizeAndScaleAnchor (const RelativePoint& p, UndoManager* undoManager) +void DrawableText::ValueTreeWrapper::setFontSizeControlPoint (const RelativePoint& p, UndoManager* undoManager) { state.setProperty (fontSizeAnchor, p.toString(), undoManager); } +//============================================================================== const Rectangle DrawableText::refreshFromValueTree (const ValueTree& tree, ImageProvider*) { ValueTreeWrapper v (tree); setName (v.getID()); const RelativeParallelogram newBounds (v.getBoundingBox()); - const RelativePoint newFontPoint (v.getFontSizeAndScaleAnchor()); + const RelativePoint newFontPoint (v.getFontSizeControlPoint()); const Colour newColour (v.getColour()); const Justification newJustification (v.getJustification()); const String newText (v.getText()); @@ -275,7 +276,7 @@ const ValueTree DrawableText::createValueTree (ImageProvider*) const v.setJustification (justification, 0); v.setColour (colour, 0); v.setBoundingBox (bounds, 0); - v.setFontSizeAndScaleAnchor (fontSizeControlPoint, 0); + v.setFontSizeControlPoint (fontSizeControlPoint, 0); return tree; } diff --git a/src/gui/graphics/drawables/juce_DrawableText.h b/src/gui/graphics/drawables/juce_DrawableText.h index 242929a525..2c0b5aca39 100644 --- a/src/gui/graphics/drawables/juce_DrawableText.h +++ b/src/gui/graphics/drawables/juce_DrawableText.h @@ -129,8 +129,8 @@ public: const RelativeParallelogram getBoundingBox() const; void setBoundingBox (const RelativeParallelogram& newBounds, UndoManager* undoManager); - const RelativePoint getFontSizeAndScaleAnchor() const; - void setFontSizeAndScaleAnchor (const RelativePoint& p, UndoManager* undoManager); + const RelativePoint getFontSizeControlPoint() const; + void setFontSizeControlPoint (const RelativePoint& p, UndoManager* undoManager); static const Identifier text, colour, font, justification, topLeft, topRight, bottomLeft, fontSizeAnchor; }; diff --git a/src/io/network/juce_URL.cpp b/src/io/network/juce_URL.cpp index 3a014d63d8..25c4a879b4 100644 --- a/src/io/network/juce_URL.cpp +++ b/src/io/network/juce_URL.cpp @@ -403,12 +403,15 @@ private: } data << "--\r\n"; + data.flush(); } else { data << getMangledParameters (url.getParameters()) << url.getPostData(); + data.flush(); + // just a short text attachment, so use simple url encoding.. headers = "Content-Type: application/x-www-form-urlencoded\r\nContent-length: " + String ((unsigned int) postData.getSize()) diff --git a/src/native/common/juce_posix_SharedCode.h b/src/native/common/juce_posix_SharedCode.h index 73124dd9ac..7ca97a16ab 100644 --- a/src/native/common/juce_posix_SharedCode.h +++ b/src/native/common/juce_posix_SharedCode.h @@ -70,7 +70,11 @@ public: manualReset (manualReset_) { pthread_cond_init (&condition, 0); - pthread_mutex_init (&mutex, 0); + + pthread_mutexattr_t atts; + pthread_mutexattr_init (&atts); + pthread_mutexattr_setprotocol (&atts, PTHREAD_PRIO_INHERIT); + pthread_mutex_init (&mutex, &atts); } ~WaitableEventImpl() diff --git a/src/native/linux/juce_linux_Messaging.cpp b/src/native/linux/juce_linux_Messaging.cpp index dc518e893e..4953c80a74 100644 --- a/src/native/linux/juce_linux_Messaging.cpp +++ b/src/native/linux/juce_linux_Messaging.cpp @@ -254,11 +254,10 @@ namespace LinuxErrorHandling static int ioErrorHandler (Display* display) { DBG ("ERROR: connection to X server broken.. terminating."); - errorOccurred = true; if (JUCEApplication::getInstance() != 0) - Process::terminate(); + MessageManager::getInstance()->stopDispatchLoop(); return 0; } diff --git a/src/native/linux/juce_linux_Network.cpp b/src/native/linux/juce_linux_Network.cpp index 00418c8444..e20af264a9 100644 --- a/src/native/linux/juce_linux_Network.cpp +++ b/src/native/linux/juce_linux_Network.cpp @@ -463,10 +463,10 @@ void juce_getInternetFileHeaders (void* handle, StringPairArray& headers) for (int i = 0; i < s->headerLines.size(); ++i) { const String& headersEntry = s->headerLines[i]; - const String key (headersEntry.upToFirstOccurrenceOf (": ", false, false)); - const String value (headersEntry.fromFirstOccurrenceOf (": ", false, false)); + const String key (headersEntry.upToFirstOccurrenceOf ("; ", false, false)); + const String value (headersEntry.fromFirstOccurrenceOf ("; ", false, false)); const String previousValue (headers [key]); - headers.set (key, previousValue.isEmpty() ? value : (previousValue + ";" + value)); + headers.set (key, previousValue.isEmpty() ? value : (previousValue + "," + value)); } } } diff --git a/src/native/mac/juce_mac_Network.mm b/src/native/mac/juce_mac_Network.mm index dbe4db651d..bb406af98f 100644 --- a/src/native/mac/juce_mac_Network.mm +++ b/src/native/mac/juce_mac_Network.mm @@ -232,8 +232,12 @@ public: - (void) createConnection { + NSInteger oldRetainCount = [self retainCount]; connection = [[NSURLConnection alloc] initWithRequest: request - delegate: [self retain]]; + delegate: self]; + + if (oldRetainCount == [self retainCount]) + [self retain]; // newer SDK should already retain this, but there were problems in older versions.. if (connection == nil) runLoopThread->signalThreadShouldExit(); diff --git a/src/native/windows/juce_win32_Network.cpp b/src/native/windows/juce_win32_Network.cpp index fd5b52af51..0c6e1ca31b 100644 --- a/src/native/windows/juce_win32_Network.cpp +++ b/src/native/windows/juce_win32_Network.cpp @@ -169,7 +169,7 @@ void* juce_openInternetFile (const String& url, { const TCHAR* mimeTypes[] = { _T("*/*"), 0 }; - DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE; + DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES; if (url.startsWithIgnoreCase ("https:")) flags |= INTERNET_FLAG_SECURE; // (this flag only seems necessary if the OS is running IE6 - @@ -214,7 +214,9 @@ void* juce_openInternetFile (const String& url, result->connection = connection; result->request = request; - HttpEndRequest (request, 0, 0, 0); + if (! HttpEndRequest (request, 0, 0, 0)) + break; + return result; } @@ -296,11 +298,11 @@ void juce_getInternetFileHeaders (void* handle, StringPairArray& headers) for (int i = 0; i < headersArray.size(); ++i) { const String& header = headersArray[i]; - const String key (header.upToFirstOccurrenceOf (": ", false, false)); - const String value (header.fromFirstOccurrenceOf (": ", false, false)); + const String key (header.upToFirstOccurrenceOf ("; ", false, false)); + const String value (header.fromFirstOccurrenceOf ("; ", false, false)); const String previousValue (headers [key]); - headers.set (key, previousValue.isEmpty() ? value : (previousValue + ";" + value)); + headers.set (key, previousValue.isEmpty() ? value : (previousValue + "," + value)); } break;