1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Fixed a few minor warnings found by valgrind.

This commit is contained in:
Julian Storer 2010-04-15 20:51:51 +01:00
parent 258b3eff81
commit 0fe89aa299
16 changed files with 335 additions and 285 deletions

View file

@ -63,6 +63,7 @@ public:
~ComponentBoundsEditor()
{
deleteAllChildren();
}
void resized()

View file

@ -287,6 +287,7 @@ public:
~Canvas()
{
getDocument().getRoot().removeListener (this);
componentHolder->deleteAllChildren();
deleteAllChildren();
}
@ -305,11 +306,11 @@ public:
g.setFont (border.getTop() - 5.0f);
g.setColour (Colours::darkgrey);
const float x = border.getLeft();
const float y = border.getTop();
const int x = border.getLeft();
const int y = border.getTop();
g.drawHorizontalLine (y, 2.0f, getWidth() - border.getRight());
g.drawVerticalLine (x, 2.0f, getHeight() - border.getBottom());
g.drawHorizontalLine (y, 2.0f, (float) getWidth() - border.getRight());
g.drawVerticalLine (x, 2.0f, (float) getHeight() - border.getBottom());
{
TickIterator ticks (0, componentHolder->getWidth(), 1.0, 10, 50);
@ -321,8 +322,8 @@ public:
{
if (pos > 0)
{
g.drawVerticalLine (x + pos, y - tickLength * y, y);
g.drawSingleLineText (label, x + pos + 2, y - 6);
g.drawVerticalLine (x + (int) pos, y - tickLength * y, (float) y);
g.drawSingleLineText (label, x + (int) pos + 2, (int) y - 6);
}
}
}
@ -337,10 +338,10 @@ public:
{
if (pos > 0)
{
g.drawHorizontalLine (y + pos, x - tickLength * x, x);
g.drawHorizontalLine (y + (int) pos, x - tickLength * x, (float) x);
g.drawTextAsPath (label, AffineTransform::rotation (float_Pi / -2.0f)
.translated (x - 6, y + pos - 2));
.translated (x - 6.0f, y + pos - 2.0f));
}
}
}

View file

@ -600,9 +600,9 @@ public:
#import <IOKit/pwr_mgt/IOPMLib.h>
#include <Carbon/Carbon.h>
#include <sys/dir.h>
#include <sys/socket.h>
#endif
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/stat.h>
#include <sys/param.h>
@ -1441,6 +1441,15 @@ void JUCE_PUBLIC_FUNCTION initialiseJuce_NonGUI()
static_jassert (sizeof (pointer_sized_int) == sizeof (void*));
static_jassert (sizeof (int8) == 1);
static_jassert (sizeof (uint8) == 1);
static_jassert (sizeof (int16) == 2);
static_jassert (sizeof (uint16) == 2);
static_jassert (sizeof (int32) == 4);
static_jassert (sizeof (uint32) == 4);
static_jassert (sizeof (int64) == 8);
static_jassert (sizeof (uint64) == 8);
char a1[7];
jassert (numElementsInArray(a1) == 7);
int a2[3];
@ -10159,7 +10168,7 @@ public:
text[0] = 0;
}
static juce_wchar* create (const size_t numChars)
static juce_wchar* createUninitialised (const size_t numChars)
{
StringHolder* const s = reinterpret_cast <StringHolder*> (new char [sizeof (StringHolder) + numChars * sizeof (juce_wchar)]);
s->refCount = 0;
@ -10167,6 +10176,20 @@ public:
return &(s->text[0]);
}
static juce_wchar* createCopy (const juce_wchar* const src, const size_t numChars)
{
juce_wchar* const dest = createUninitialised (numChars);
copyChars (dest, src, numChars);
return dest;
}
static juce_wchar* createCopy (const char* const src, const size_t numChars)
{
juce_wchar* const dest = createUninitialised (numChars);
CharacterFunctions::copy (dest, src, numChars + 1);
return dest;
}
static inline juce_wchar* getEmpty() throw()
{
return &(empty.text[0]);
@ -10195,8 +10218,7 @@ public:
if (b->refCount <= 0)
return text;
juce_wchar* const newText = create (b->allocatedNumChars);
copyChars (newText, text, b->allocatedNumChars);
juce_wchar* const newText = createCopy (text, b->allocatedNumChars);
release (b);
return newText;
@ -10209,7 +10231,7 @@ public:
if (b->refCount <= 0 && b->allocatedNumChars >= numChars)
return text;
juce_wchar* const newText = create (jmax (b->allocatedNumChars, numChars));
juce_wchar* const newText = createUninitialised (jmax (b->allocatedNumChars, numChars));
copyChars (newText, text, b->allocatedNumChars);
release (b);
@ -10249,8 +10271,7 @@ void String::createInternal (const juce_wchar* const t, const size_t numChars)
{
jassert (t[numChars] == 0); // must have a null terminator
text = StringHolder::create (numChars);
StringHolder::copyChars (text, t, numChars);
text = StringHolder::createCopy (t, numChars);
}
void String::appendInternal (const juce_wchar* const newText, const int numExtraChars)
@ -10300,43 +10321,31 @@ String& String::operator= (const String& other) throw()
}
String::String (const size_t numChars, const int /*dummyVariable*/)
: text (StringHolder::create (numChars))
: text (StringHolder::createUninitialised (numChars))
{
}
String::String (const String& stringToCopy, const size_t charsToAllocate)
{
const size_t otherSize = StringHolder::getAllocatedNumChars (stringToCopy.text);
text = StringHolder::create (jmax (charsToAllocate, otherSize));
text = StringHolder::createUninitialised (jmax (charsToAllocate, otherSize));
StringHolder::copyChars (text, stringToCopy.text, otherSize);
}
String::String (const char* const t)
{
if (t != 0 && *t != 0)
{
const int len = CharacterFunctions::length (t);
text = StringHolder::create (len);
CharacterFunctions::copy (text, t, len + 1);
}
text = StringHolder::createCopy (t, CharacterFunctions::length (t));
else
{
text = StringHolder::getEmpty();
}
}
String::String (const juce_wchar* const t)
{
if (t != 0 && *t != 0)
{
const int len = CharacterFunctions::length (t);
text = StringHolder::create (len);
StringHolder::copyChars (text, t, len);
}
text = StringHolder::createCopy (t, CharacterFunctions::length (t));
else
{
text = StringHolder::getEmpty();
}
}
String::String (const char* const t, const size_t maxChars)
@ -10347,15 +10356,9 @@ String::String (const char* const t, const size_t maxChars)
break;
if (i > 0)
{
text = StringHolder::create (i);
CharacterFunctions::copy (text, t, i);
text[i] = 0;
}
text = StringHolder::createCopy (t, i);
else
{
text = StringHolder::getEmpty();
}
}
String::String (const juce_wchar* const t, const size_t maxChars)
@ -10366,14 +10369,9 @@ String::String (const juce_wchar* const t, const size_t maxChars)
break;
if (i > 0)
{
text = StringHolder::create (i);
StringHolder::copyChars (text, t, i);
}
text = StringHolder::createCopy (t, i);
else
{
text = StringHolder::getEmpty();
}
}
const String String::charToString (const juce_wchar character)
@ -44080,6 +44078,7 @@ class CodeEditorComponent::CodeEditorLine
{
public:
CodeEditorLine() throw()
: highlightColumnStart (0), highlightColumnEnd (0)
{
}
@ -57350,15 +57349,13 @@ class FileListItemComponent : public Component,
{
public:
FileListItemComponent (FileListComponent& owner_,
TimeSliceThread& thread_) throw()
: owner (owner_),
thread (thread_),
icon (0)
FileListItemComponent (FileListComponent& owner_, TimeSliceThread& thread_)
: owner (owner_), thread (thread_),
highlighted (false), index (0), icon (0)
{
}
~FileListItemComponent() throw()
~FileListItemComponent()
{
thread.removeTimeSliceClient (this);
@ -57389,7 +57386,7 @@ public:
void update (const File& root,
const DirectoryContentsList::FileInfo* const fileInfo,
const int index_,
const bool highlighted_) throw()
const bool highlighted_)
{
thread.removeTimeSliceClient (this);
@ -57460,13 +57457,13 @@ private:
Image* icon;
bool isDirectory;
void clearIcon() throw()
void clearIcon()
{
ImageCache::release (icon);
icon = 0;
}
void updateIcon (const bool onlyUpdateIfCached) throw()
void updateIcon (const bool onlyUpdateIfCached)
{
if (icon == 0)
{
@ -69440,107 +69437,133 @@ END_JUCE_NAMESPACE
/*** Start of inlined file: juce_MouseCursor.cpp ***/
BEGIN_JUCE_NAMESPACE
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) throw();
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) throw();
// isStandard set depending on which interface was used to create the cursor
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw();
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY);
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type);
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard);
static CriticalSection activeCursorListLock;
static VoidArray activeCursors;
class SharedMouseCursorInternal : public ReferenceCountedObject
class MouseCursor::SharedCursorHandle
{
public:
SharedMouseCursorInternal (const MouseCursor::StandardCursorType type) throw()
: standardType (type),
explicit SharedCursorHandle (const MouseCursor::StandardCursorType type)
: handle (juce_createStandardMouseCursor (type)),
refCount (1),
standardType (type),
isStandard (true)
{
handle = juce_createStandardMouseCursor (standardType);
activeCursors.add (this);
}
SharedMouseCursorInternal (const Image& image, const int hotSpotX, const int hotSpotY) throw()
: standardType (MouseCursor::NormalCursor),
SharedCursorHandle (const Image& image, const int hotSpotX, const int hotSpotY)
: handle (juce_createMouseCursorFromImage (image, hotSpotX, hotSpotY)),
refCount (1),
standardType (MouseCursor::NormalCursor),
isStandard (false)
{
handle = juce_createMouseCursorFromImage (image, hotSpotX, hotSpotY);
}
~SharedMouseCursorInternal() throw()
static SharedCursorHandle* createStandard (const MouseCursor::StandardCursorType type)
{
juce_deleteMouseCursor (handle, isStandard);
activeCursors.removeValue (this);
}
const ScopedLock sl (lock);
void* getHandle() const throw()
{
return handle;
}
static SharedMouseCursorInternal* findInstance (MouseCursor::StandardCursorType type) throw()
{
for (int i = activeCursors.size(); --i >= 0;)
for (int i = standardCursors.size(); --i >= 0;)
{
SharedMouseCursorInternal* const r = static_cast <SharedMouseCursorInternal*> (activeCursors.getUnchecked(i));
SharedCursorHandle* const sc = standardCursors.getUnchecked(i);
if (r->standardType == type)
return r;
if (sc->standardType == type)
return sc->retain();
}
return new SharedMouseCursorInternal (type);
SharedCursorHandle* const sc = new SharedCursorHandle (type);
standardCursors.add (sc);
return sc;
}
SharedCursorHandle* retain() throw()
{
Atomic::increment (refCount);
return this;
}
void release()
{
if (Atomic::decrementAndReturn (refCount) == 0)
{
if (isStandard)
{
const ScopedLock sl (lock);
standardCursors.removeValue (this);
}
delete this;
}
}
void* getHandle() const throw() { return handle; }
juce_UseDebuggingNewOperator
private:
void* handle;
void* const handle;
int32 refCount;
const MouseCursor::StandardCursorType standardType;
const bool isStandard;
SharedMouseCursorInternal& operator= (const SharedMouseCursorInternal&);
static CriticalSection lock;
static Array <SharedCursorHandle*> standardCursors;
~SharedCursorHandle()
{
juce_deleteMouseCursor (handle, isStandard);
}
SharedCursorHandle& operator= (const SharedCursorHandle&);
};
MouseCursor::MouseCursor() throw()
CriticalSection MouseCursor::SharedCursorHandle::lock;
Array <MouseCursor::SharedCursorHandle*> MouseCursor::SharedCursorHandle::standardCursors;
MouseCursor::MouseCursor()
: cursorHandle (SharedCursorHandle::createStandard (NormalCursor))
{
const ScopedLock sl (activeCursorListLock);
cursorHandle = SharedMouseCursorInternal::findInstance (NormalCursor);
jassert (cursorHandle != 0);
}
MouseCursor::MouseCursor (const StandardCursorType type) throw()
MouseCursor::MouseCursor (const StandardCursorType type)
: cursorHandle (SharedCursorHandle::createStandard (type))
{
const ScopedLock sl (activeCursorListLock);
cursorHandle = SharedMouseCursorInternal::findInstance (type);
jassert (cursorHandle != 0);
}
MouseCursor::MouseCursor (const Image& image, const int hotSpotX, const int hotSpotY) throw()
{
const ScopedLock sl (activeCursorListLock);
cursorHandle = new SharedMouseCursorInternal (image, hotSpotX, hotSpotY);
}
MouseCursor::MouseCursor (const MouseCursor& other) throw()
: cursorHandle (other.cursorHandle)
MouseCursor::MouseCursor (const Image& image, const int hotSpotX, const int hotSpotY)
: cursorHandle (new SharedCursorHandle (image, hotSpotX, hotSpotY))
{
}
MouseCursor::~MouseCursor() throw()
MouseCursor::MouseCursor (const MouseCursor& other)
: cursorHandle (other.cursorHandle->retain())
{
}
MouseCursor& MouseCursor::operator= (const MouseCursor& other) throw()
MouseCursor::~MouseCursor()
{
cursorHandle->release();
}
MouseCursor& MouseCursor::operator= (const MouseCursor& other)
{
other.cursorHandle->retain();
cursorHandle->release();
cursorHandle = other.cursorHandle;
return *this;
}
bool MouseCursor::operator== (const MouseCursor& other) const throw()
{
return cursorHandle == other.cursorHandle;
return getHandle() == other.getHandle();
}
bool MouseCursor::operator!= (const MouseCursor& other) const throw()
{
return cursorHandle != other.cursorHandle;
return getHandle() != other.getHandle();
}
void* MouseCursor::getHandle() const throw()
@ -77384,6 +77407,7 @@ TooltipWindow::TooltipWindow (Component* const parentComponent,
const int millisecondsBeforeTipAppears_)
: Component ("tooltip"),
millisecondsBeforeTipAppears (millisecondsBeforeTipAppears_),
mouseClicks (0),
lastHideTime (0),
lastComponentUnderMouse (0),
changedCompsSinceShown (true)
@ -216023,7 +216047,7 @@ Image* juce_createIconForFile (const File& file)
return image;
}
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) throw()
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY)
{
const int maxW = GetSystemMetrics (SM_CXCURSOR);
const int maxH = GetSystemMetrics (SM_CYCURSOR);
@ -216079,13 +216103,13 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot
return cursorH;
}
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw()
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard)
{
if (cursorHandle != 0 && ! isStandard)
DestroyCursor ((HCURSOR) cursorHandle);
}
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) throw()
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type)
{
LPCTSTR cursorName = IDC_ARROW;
@ -216171,12 +216195,12 @@ void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) thro
return cursorH;
}
void MouseCursor::showInWindow (ComponentPeer*) const throw()
void MouseCursor::showInWindow (ComponentPeer*) const
{
SetCursor ((HCURSOR) getHandle());
}
void MouseCursor::showInAllWindows() const throw()
void MouseCursor::showInAllWindows() const
{
showInWindow (0);
}
@ -233713,7 +233737,7 @@ bool Desktop::isScreenSaverEnabled() throw()
return screenSaverAllowed;
}
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) throw()
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY)
{
ScopedXLock xlock;
const unsigned int imageW = image.getWidth();
@ -233838,14 +233862,14 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot
return result;
}
void juce_deleteMouseCursor (void* const cursorHandle, const bool) throw()
void juce_deleteMouseCursor (void* const cursorHandle, const bool)
{
ScopedXLock xlock;
if (cursorHandle != 0)
XFreeCursor (display, (Cursor) cursorHandle);
}
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) throw()
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type)
{
unsigned int shape;
@ -233955,7 +233979,7 @@ void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) thro
return (void*) XCreateFontCursor (display, shape);
}
void MouseCursor::showInWindow (ComponentPeer* peer) const throw()
void MouseCursor::showInWindow (ComponentPeer* peer) const
{
LinuxComponentPeer* const lp = dynamic_cast <LinuxComponentPeer*> (peer);
@ -233963,7 +233987,7 @@ void MouseCursor::showInWindow (ComponentPeer* peer) const throw()
lp->showMouseCursor ((Cursor) getHandle());
}
void MouseCursor::showInAllWindows() const throw()
void MouseCursor::showInAllWindows() const
{
for (int i = ComponentPeer::getNumPeers(); --i >= 0;)
showInWindow (ComponentPeer::getPeer (i));
@ -242146,7 +242170,7 @@ void juce_glViewport (const int w, const int h)
Image* juce_loadPNGImageFromStream (InputStream& inputStream);
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) throw()
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY)
{
NSImage* im = CoreGraphicsImage::createNSImage (image);
NSCursor* c = [[NSCursor alloc] initWithImage: im
@ -242156,9 +242180,9 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot
return c;
}
static void* juce_cursorFromData (const unsigned char* data, const size_t size, float hx, float hy) throw()
static void* juce_cursorFromData (const MemoryBlock& data, const float hx, const float hy)
{
MemoryInputStream stream (data, size, false);
MemoryInputStream stream (data, false);
ScopedPointer <Image> im (juce_loadPNGImageFromStream (stream));
jassert (im != 0);
@ -242172,16 +242196,16 @@ static void* juce_cursorFromData (const unsigned char* data, const size_t size,
static void* juce_cursorFromWebKitFile (const char* filename, float hx, float hy)
{
File f ("/System/Library/Frameworks/WebKit.framework/Frameworks/WebCore.framework/Resources");
const File f ("/System/Library/Frameworks/WebKit.framework/Frameworks/WebCore.framework/Resources");
MemoryBlock mb;
if (f.getChildFile (filename).loadFileAsData (mb))
return juce_cursorFromData ((const unsigned char*) mb.getData(), mb.getSize(), hx, hy);
return juce_cursorFromData (mb, hx, hy);
return 0;
}
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) throw()
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type)
{
const ScopedAutoReleasePool pool;
NSCursor* c = 0;
@ -242252,18 +242276,18 @@ void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) thro
return c;
}
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw()
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard)
{
NSCursor* c = (NSCursor*) cursorHandle;
[c release];
}
void MouseCursor::showInAllWindows() const throw()
void MouseCursor::showInAllWindows() const
{
showInWindow (0);
}
void MouseCursor::showInWindow (ComponentPeer*) const throw()
void MouseCursor::showInWindow (ComponentPeer*) const
{
NSCursor* const c = (NSCursor*) getHandle();
[c set];
@ -242271,11 +242295,11 @@ void MouseCursor::showInWindow (ComponentPeer*) const throw()
#else
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) throw() { return 0; }
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) throw() { return 0; }
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw() {}
void MouseCursor::showInAllWindows() const throw() {}
void MouseCursor::showInWindow (ComponentPeer*) const throw() {}
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) { return 0; }
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) { return 0; }
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) {}
void MouseCursor::showInAllWindows() const {}
void MouseCursor::showInWindow (ComponentPeer*) const {}
#endif
@ -246681,7 +246705,7 @@ const int KeyPress::rewindKey = 0x30003;
Image* juce_loadPNGImageFromStream (InputStream& inputStream);
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) throw()
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY)
{
NSImage* im = CoreGraphicsImage::createNSImage (image);
NSCursor* c = [[NSCursor alloc] initWithImage: im
@ -246691,9 +246715,9 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot
return c;
}
static void* juce_cursorFromData (const unsigned char* data, const size_t size, float hx, float hy) throw()
static void* juce_cursorFromData (const MemoryBlock& data, const float hx, const float hy)
{
MemoryInputStream stream (data, size, false);
MemoryInputStream stream (data, false);
ScopedPointer <Image> im (juce_loadPNGImageFromStream (stream));
jassert (im != 0);
@ -246707,16 +246731,16 @@ static void* juce_cursorFromData (const unsigned char* data, const size_t size,
static void* juce_cursorFromWebKitFile (const char* filename, float hx, float hy)
{
File f ("/System/Library/Frameworks/WebKit.framework/Frameworks/WebCore.framework/Resources");
const File f ("/System/Library/Frameworks/WebKit.framework/Frameworks/WebCore.framework/Resources");
MemoryBlock mb;
if (f.getChildFile (filename).loadFileAsData (mb))
return juce_cursorFromData ((const unsigned char*) mb.getData(), mb.getSize(), hx, hy);
return juce_cursorFromData (mb, hx, hy);
return 0;
}
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) throw()
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type)
{
const ScopedAutoReleasePool pool;
NSCursor* c = 0;
@ -246787,18 +246811,18 @@ void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) thro
return c;
}
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw()
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard)
{
NSCursor* c = (NSCursor*) cursorHandle;
[c release];
}
void MouseCursor::showInAllWindows() const throw()
void MouseCursor::showInAllWindows() const
{
showInWindow (0);
}
void MouseCursor::showInWindow (ComponentPeer*) const throw()
void MouseCursor::showInWindow (ComponentPeer*) const
{
NSCursor* const c = (NSCursor*) getHandle();
[c set];
@ -246806,11 +246830,11 @@ void MouseCursor::showInWindow (ComponentPeer*) const throw()
#else
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) throw() { return 0; }
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) throw() { return 0; }
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw() {}
void MouseCursor::showInAllWindows() const throw() {}
void MouseCursor::showInWindow (ComponentPeer*) const throw() {}
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) { return 0; }
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) { return 0; }
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) {}
void MouseCursor::showInAllWindows() const {}
void MouseCursor::showInWindow (ComponentPeer*) const {}
#endif

View file

@ -3247,7 +3247,7 @@ protected:
private:
int refCounts;
int32 refCounts;
};
template <class ReferenceCountedObjectClass>
@ -9265,7 +9265,6 @@ private:
#define __JUCE_MOUSECURSOR_JUCEHEADER__
class Image;
class SharedMouseCursorInternal;
class ComponentPeer;
class Component;
@ -9301,17 +9300,17 @@ public:
BottomRightCornerResizeCursor /**< A platform-specific cursor for resizing the bottom-right-corner of a window. */
};
MouseCursor() throw();
MouseCursor();
MouseCursor (StandardCursorType type) throw();
MouseCursor (StandardCursorType type);
MouseCursor (const Image& image, int hotSpotX, int hotSpotY) throw();
MouseCursor (const Image& image, int hotSpotX, int hotSpotY);
MouseCursor (const MouseCursor& other) throw();
MouseCursor (const MouseCursor& other);
MouseCursor& operator= (const MouseCursor& other) throw();
MouseCursor& operator= (const MouseCursor& other);
~MouseCursor() throw();
~MouseCursor();
bool operator== (const MouseCursor& other) const throw();
@ -9324,11 +9323,12 @@ public:
juce_UseDebuggingNewOperator
private:
ReferenceCountedObjectPtr <SharedMouseCursorInternal> cursorHandle;
class SharedCursorHandle;
SharedCursorHandle* cursorHandle;
friend class MouseInputSourceInternal;
void showInWindow (ComponentPeer* window) const throw();
void showInAllWindows() const throw();
void showInWindow (ComponentPeer* window) const;
void showInAllWindows() const;
void* getHandle() const throw();
};

View file

@ -109,7 +109,7 @@ protected:
private:
//==============================================================================
int refCounts;
int32 refCounts;
};

View file

@ -85,6 +85,15 @@ void JUCE_PUBLIC_FUNCTION initialiseJuce_NonGUI()
static_jassert (sizeof (pointer_sized_int) == sizeof (void*));
static_jassert (sizeof (int8) == 1);
static_jassert (sizeof (uint8) == 1);
static_jassert (sizeof (int16) == 2);
static_jassert (sizeof (uint16) == 2);
static_jassert (sizeof (int32) == 4);
static_jassert (sizeof (uint32) == 4);
static_jassert (sizeof (int64) == 8);
static_jassert (sizeof (uint64) == 8);
char a1[7];
jassert (numElementsInArray(a1) == 7);
int a2[3];

View file

@ -77,6 +77,7 @@ class CodeEditorComponent::CodeEditorLine
{
public:
CodeEditorLine() throw()
: highlightColumnStart (0), highlightColumnEnd (0)
{
}

View file

@ -84,15 +84,13 @@ class FileListItemComponent : public Component,
{
public:
//==============================================================================
FileListItemComponent (FileListComponent& owner_,
TimeSliceThread& thread_) throw()
: owner (owner_),
thread (thread_),
icon (0)
FileListItemComponent (FileListComponent& owner_, TimeSliceThread& thread_)
: owner (owner_), thread (thread_),
highlighted (false), index (0), icon (0)
{
}
~FileListItemComponent() throw()
~FileListItemComponent()
{
thread.removeTimeSliceClient (this);
@ -124,7 +122,7 @@ public:
void update (const File& root,
const DirectoryContentsList::FileInfo* const fileInfo,
const int index_,
const bool highlighted_) throw()
const bool highlighted_)
{
thread.removeTimeSliceClient (this);
@ -196,13 +194,13 @@ private:
Image* icon;
bool isDirectory;
void clearIcon() throw()
void clearIcon()
{
ImageCache::release (icon);
icon = 0;
}
void updateIcon (const bool onlyUpdateIfCached) throw()
void updateIcon (const bool onlyUpdateIfCached)
{
if (icon == 0)
{

View file

@ -33,113 +33,139 @@ BEGIN_JUCE_NAMESPACE
#include "../mouse/juce_MouseInputSource.h"
#include "../../../threads/juce_ScopedLock.h"
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) throw();
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) throw();
// isStandard set depending on which interface was used to create the cursor
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw();
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY);
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type);
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard);
//==============================================================================
static CriticalSection activeCursorListLock;
static VoidArray activeCursors;
//==============================================================================
class SharedMouseCursorInternal : public ReferenceCountedObject
class MouseCursor::SharedCursorHandle
{
public:
SharedMouseCursorInternal (const MouseCursor::StandardCursorType type) throw()
: standardType (type),
explicit SharedCursorHandle (const MouseCursor::StandardCursorType type)
: handle (juce_createStandardMouseCursor (type)),
refCount (1),
standardType (type),
isStandard (true)
{
handle = juce_createStandardMouseCursor (standardType);
activeCursors.add (this);
}
SharedMouseCursorInternal (const Image& image, const int hotSpotX, const int hotSpotY) throw()
: standardType (MouseCursor::NormalCursor),
SharedCursorHandle (const Image& image, const int hotSpotX, const int hotSpotY)
: handle (juce_createMouseCursorFromImage (image, hotSpotX, hotSpotY)),
refCount (1),
standardType (MouseCursor::NormalCursor),
isStandard (false)
{
handle = juce_createMouseCursorFromImage (image, hotSpotX, hotSpotY);
}
~SharedMouseCursorInternal() throw()
static SharedCursorHandle* createStandard (const MouseCursor::StandardCursorType type)
{
juce_deleteMouseCursor (handle, isStandard);
activeCursors.removeValue (this);
}
const ScopedLock sl (lock);
void* getHandle() const throw()
{
return handle;
}
static SharedMouseCursorInternal* findInstance (MouseCursor::StandardCursorType type) throw()
{
for (int i = activeCursors.size(); --i >= 0;)
for (int i = standardCursors.size(); --i >= 0;)
{
SharedMouseCursorInternal* const r = static_cast <SharedMouseCursorInternal*> (activeCursors.getUnchecked(i));
SharedCursorHandle* const sc = standardCursors.getUnchecked(i);
if (r->standardType == type)
return r;
if (sc->standardType == type)
return sc->retain();
}
return new SharedMouseCursorInternal (type);
SharedCursorHandle* const sc = new SharedCursorHandle (type);
standardCursors.add (sc);
return sc;
}
SharedCursorHandle* retain() throw()
{
Atomic::increment (refCount);
return this;
}
void release()
{
if (Atomic::decrementAndReturn (refCount) == 0)
{
if (isStandard)
{
const ScopedLock sl (lock);
standardCursors.removeValue (this);
}
delete this;
}
}
void* getHandle() const throw() { return handle; }
//==============================================================================
juce_UseDebuggingNewOperator
private:
void* handle;
void* const handle;
int32 refCount;
const MouseCursor::StandardCursorType standardType;
const bool isStandard;
SharedMouseCursorInternal& operator= (const SharedMouseCursorInternal&);
static CriticalSection lock;
static Array <SharedCursorHandle*> standardCursors;
~SharedCursorHandle()
{
juce_deleteMouseCursor (handle, isStandard);
}
SharedCursorHandle& operator= (const SharedCursorHandle&);
};
CriticalSection MouseCursor::SharedCursorHandle::lock;
Array <MouseCursor::SharedCursorHandle*> MouseCursor::SharedCursorHandle::standardCursors;
//==============================================================================
MouseCursor::MouseCursor() throw()
MouseCursor::MouseCursor()
: cursorHandle (SharedCursorHandle::createStandard (NormalCursor))
{
const ScopedLock sl (activeCursorListLock);
cursorHandle = SharedMouseCursorInternal::findInstance (NormalCursor);
jassert (cursorHandle != 0);
}
MouseCursor::MouseCursor (const StandardCursorType type) throw()
MouseCursor::MouseCursor (const StandardCursorType type)
: cursorHandle (SharedCursorHandle::createStandard (type))
{
const ScopedLock sl (activeCursorListLock);
cursorHandle = SharedMouseCursorInternal::findInstance (type);
jassert (cursorHandle != 0);
}
MouseCursor::MouseCursor (const Image& image, const int hotSpotX, const int hotSpotY) throw()
{
const ScopedLock sl (activeCursorListLock);
cursorHandle = new SharedMouseCursorInternal (image, hotSpotX, hotSpotY);
}
MouseCursor::MouseCursor (const MouseCursor& other) throw()
: cursorHandle (other.cursorHandle)
MouseCursor::MouseCursor (const Image& image, const int hotSpotX, const int hotSpotY)
: cursorHandle (new SharedCursorHandle (image, hotSpotX, hotSpotY))
{
}
MouseCursor::~MouseCursor() throw()
MouseCursor::MouseCursor (const MouseCursor& other)
: cursorHandle (other.cursorHandle->retain())
{
}
MouseCursor& MouseCursor::operator= (const MouseCursor& other) throw()
MouseCursor::~MouseCursor()
{
cursorHandle->release();
}
MouseCursor& MouseCursor::operator= (const MouseCursor& other)
{
other.cursorHandle->retain();
cursorHandle->release();
cursorHandle = other.cursorHandle;
return *this;
}
bool MouseCursor::operator== (const MouseCursor& other) const throw()
{
return cursorHandle == other.cursorHandle;
return getHandle() == other.getHandle();
}
bool MouseCursor::operator!= (const MouseCursor& other) const throw()
{
return cursorHandle != other.cursorHandle;
return getHandle() != other.getHandle();
}
void* MouseCursor::getHandle() const throw()

View file

@ -28,7 +28,6 @@
#include "../../../containers/juce_ReferenceCountedObject.h"
class Image;
class SharedMouseCursorInternal;
class ComponentPeer;
class Component;
@ -75,10 +74,10 @@ public:
//==============================================================================
/** Creates the standard arrow cursor. */
MouseCursor() throw();
MouseCursor();
/** Creates one of the standard mouse cursor */
MouseCursor (StandardCursorType type) throw();
MouseCursor (StandardCursorType type);
/** Creates a custom cursor from an image.
@ -89,17 +88,17 @@ public:
@param hotSpotX the x position of the cursor's hotspot within the image
@param hotSpotY the y position of the cursor's hotspot within the image
*/
MouseCursor (const Image& image, int hotSpotX, int hotSpotY) throw();
MouseCursor (const Image& image, int hotSpotX, int hotSpotY);
//==============================================================================
/** Creates a copy of another cursor object. */
MouseCursor (const MouseCursor& other) throw();
MouseCursor (const MouseCursor& other);
/** Copies this cursor from another object. */
MouseCursor& operator= (const MouseCursor& other) throw();
MouseCursor& operator= (const MouseCursor& other);
/** Destructor. */
~MouseCursor() throw();
~MouseCursor();
/** Checks whether two mouse cursors are the same.
@ -145,11 +144,12 @@ public:
juce_UseDebuggingNewOperator
private:
ReferenceCountedObjectPtr <SharedMouseCursorInternal> cursorHandle;
class SharedCursorHandle;
SharedCursorHandle* cursorHandle;
friend class MouseInputSourceInternal;
void showInWindow (ComponentPeer* window) const throw();
void showInAllWindows() const throw();
void showInWindow (ComponentPeer* window) const;
void showInAllWindows() const;
void* getHandle() const throw();
};

View file

@ -42,6 +42,7 @@ TooltipWindow::TooltipWindow (Component* const parentComponent,
const int millisecondsBeforeTipAppears_)
: Component ("tooltip"),
millisecondsBeforeTipAppears (millisecondsBeforeTipAppears_),
mouseClicks (0),
lastHideTime (0),
lastComponentUnderMouse (0),
changedCompsSinceShown (true)

View file

@ -2960,7 +2960,7 @@ bool Desktop::isScreenSaverEnabled() throw()
}
//==============================================================================
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) throw()
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY)
{
ScopedXLock xlock;
const unsigned int imageW = image.getWidth();
@ -3085,14 +3085,14 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot
return result;
}
void juce_deleteMouseCursor (void* const cursorHandle, const bool) throw()
void juce_deleteMouseCursor (void* const cursorHandle, const bool)
{
ScopedXLock xlock;
if (cursorHandle != 0)
XFreeCursor (display, (Cursor) cursorHandle);
}
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) throw()
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type)
{
unsigned int shape;
@ -3202,7 +3202,7 @@ void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) thro
return (void*) XCreateFontCursor (display, shape);
}
void MouseCursor::showInWindow (ComponentPeer* peer) const throw()
void MouseCursor::showInWindow (ComponentPeer* peer) const
{
LinuxComponentPeer* const lp = dynamic_cast <LinuxComponentPeer*> (peer);
@ -3210,7 +3210,7 @@ void MouseCursor::showInWindow (ComponentPeer* peer) const throw()
lp->showMouseCursor ((Cursor) getHandle());
}
void MouseCursor::showInAllWindows() const throw()
void MouseCursor::showInAllWindows() const
{
for (int i = ComponentPeer::getNumPeers(); --i >= 0;)
showInWindow (ComponentPeer::getPeer (i));

View file

@ -32,7 +32,7 @@
Image* juce_loadPNGImageFromStream (InputStream& inputStream);
//==============================================================================
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) throw()
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY)
{
NSImage* im = CoreGraphicsImage::createNSImage (image);
NSCursor* c = [[NSCursor alloc] initWithImage: im
@ -42,9 +42,9 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot
return c;
}
static void* juce_cursorFromData (const unsigned char* data, const size_t size, float hx, float hy) throw()
static void* juce_cursorFromData (const MemoryBlock& data, const float hx, const float hy)
{
MemoryInputStream stream (data, size, false);
MemoryInputStream stream (data, false);
ScopedPointer <Image> im (juce_loadPNGImageFromStream (stream));
jassert (im != 0);
@ -58,16 +58,16 @@ static void* juce_cursorFromData (const unsigned char* data, const size_t size,
static void* juce_cursorFromWebKitFile (const char* filename, float hx, float hy)
{
File f ("/System/Library/Frameworks/WebKit.framework/Frameworks/WebCore.framework/Resources");
const File f ("/System/Library/Frameworks/WebKit.framework/Frameworks/WebCore.framework/Resources");
MemoryBlock mb;
if (f.getChildFile (filename).loadFileAsData (mb))
return juce_cursorFromData ((const unsigned char*) mb.getData(), mb.getSize(), hx, hy);
return juce_cursorFromData (mb, hx, hy);
return 0;
}
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) throw()
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type)
{
const ScopedAutoReleasePool pool;
NSCursor* c = 0;
@ -138,18 +138,18 @@ void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) thro
return c;
}
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw()
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard)
{
NSCursor* c = (NSCursor*) cursorHandle;
[c release];
}
void MouseCursor::showInAllWindows() const throw()
void MouseCursor::showInAllWindows() const
{
showInWindow (0);
}
void MouseCursor::showInWindow (ComponentPeer*) const throw()
void MouseCursor::showInWindow (ComponentPeer*) const
{
NSCursor* const c = (NSCursor*) getHandle();
[c set];
@ -157,11 +157,11 @@ void MouseCursor::showInWindow (ComponentPeer*) const throw()
#else
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) throw() { return 0; }
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) throw() { return 0; }
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw() {}
void MouseCursor::showInAllWindows() const throw() {}
void MouseCursor::showInWindow (ComponentPeer*) const throw() {}
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) { return 0; }
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) { return 0; }
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) {}
void MouseCursor::showInAllWindows() const {}
void MouseCursor::showInWindow (ComponentPeer*) const {}
#endif

View file

@ -65,9 +65,9 @@
#import <IOKit/pwr_mgt/IOPMLib.h>
#include <Carbon/Carbon.h>
#include <sys/dir.h>
#include <sys/socket.h>
#endif
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/stat.h>
#include <sys/param.h>

View file

@ -2512,7 +2512,7 @@ Image* juce_createIconForFile (const File& file)
}
//==============================================================================
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY) throw()
void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY)
{
const int maxW = GetSystemMetrics (SM_CXCURSOR);
const int maxH = GetSystemMetrics (SM_CYCURSOR);
@ -2568,13 +2568,13 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot
return cursorH;
}
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw()
void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard)
{
if (cursorHandle != 0 && ! isStandard)
DestroyCursor ((HCURSOR) cursorHandle);
}
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) throw()
void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type)
{
LPCTSTR cursorName = IDC_ARROW;
@ -2661,12 +2661,12 @@ void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) thro
}
//==============================================================================
void MouseCursor::showInWindow (ComponentPeer*) const throw()
void MouseCursor::showInWindow (ComponentPeer*) const
{
SetCursor ((HCURSOR) getHandle());
}
void MouseCursor::showInAllWindows() const throw()
void MouseCursor::showInAllWindows() const
{
showInWindow (0);
}

View file

@ -60,7 +60,7 @@ public:
}
//==============================================================================
static juce_wchar* create (const size_t numChars)
static juce_wchar* createUninitialised (const size_t numChars)
{
StringHolder* const s = reinterpret_cast <StringHolder*> (new char [sizeof (StringHolder) + numChars * sizeof (juce_wchar)]);
s->refCount = 0;
@ -68,6 +68,20 @@ public:
return &(s->text[0]);
}
static juce_wchar* createCopy (const juce_wchar* const src, const size_t numChars)
{
juce_wchar* const dest = createUninitialised (numChars);
copyChars (dest, src, numChars);
return dest;
}
static juce_wchar* createCopy (const char* const src, const size_t numChars)
{
juce_wchar* const dest = createUninitialised (numChars);
CharacterFunctions::copy (dest, src, numChars + 1);
return dest;
}
static inline juce_wchar* getEmpty() throw()
{
return &(empty.text[0]);
@ -98,8 +112,7 @@ public:
if (b->refCount <= 0)
return text;
juce_wchar* const newText = create (b->allocatedNumChars);
copyChars (newText, text, b->allocatedNumChars);
juce_wchar* const newText = createCopy (text, b->allocatedNumChars);
release (b);
return newText;
@ -112,7 +125,7 @@ public:
if (b->refCount <= 0 && b->allocatedNumChars >= numChars)
return text;
juce_wchar* const newText = create (jmax (b->allocatedNumChars, numChars));
juce_wchar* const newText = createUninitialised (jmax (b->allocatedNumChars, numChars));
copyChars (newText, text, b->allocatedNumChars);
release (b);
@ -154,8 +167,7 @@ void String::createInternal (const juce_wchar* const t, const size_t numChars)
{
jassert (t[numChars] == 0); // must have a null terminator
text = StringHolder::create (numChars);
StringHolder::copyChars (text, t, numChars);
text = StringHolder::createCopy (t, numChars);
}
void String::appendInternal (const juce_wchar* const newText, const int numExtraChars)
@ -206,43 +218,31 @@ String& String::operator= (const String& other) throw()
}
String::String (const size_t numChars, const int /*dummyVariable*/)
: text (StringHolder::create (numChars))
: text (StringHolder::createUninitialised (numChars))
{
}
String::String (const String& stringToCopy, const size_t charsToAllocate)
{
const size_t otherSize = StringHolder::getAllocatedNumChars (stringToCopy.text);
text = StringHolder::create (jmax (charsToAllocate, otherSize));
text = StringHolder::createUninitialised (jmax (charsToAllocate, otherSize));
StringHolder::copyChars (text, stringToCopy.text, otherSize);
}
String::String (const char* const t)
{
if (t != 0 && *t != 0)
{
const int len = CharacterFunctions::length (t);
text = StringHolder::create (len);
CharacterFunctions::copy (text, t, len + 1);
}
text = StringHolder::createCopy (t, CharacterFunctions::length (t));
else
{
text = StringHolder::getEmpty();
}
}
String::String (const juce_wchar* const t)
{
if (t != 0 && *t != 0)
{
const int len = CharacterFunctions::length (t);
text = StringHolder::create (len);
StringHolder::copyChars (text, t, len);
}
text = StringHolder::createCopy (t, CharacterFunctions::length (t));
else
{
text = StringHolder::getEmpty();
}
}
String::String (const char* const t, const size_t maxChars)
@ -253,15 +253,9 @@ String::String (const char* const t, const size_t maxChars)
break;
if (i > 0)
{
text = StringHolder::create (i);
CharacterFunctions::copy (text, t, i);
text[i] = 0;
}
text = StringHolder::createCopy (t, i);
else
{
text = StringHolder::getEmpty();
}
}
String::String (const juce_wchar* const t, const size_t maxChars)
@ -272,14 +266,9 @@ String::String (const juce_wchar* const t, const size_t maxChars)
break;
if (i > 0)
{
text = StringHolder::create (i);
StringHolder::copyChars (text, t, i);
}
text = StringHolder::createCopy (t, i);
else
{
text = StringHolder::getEmpty();
}
}
const String String::charToString (const juce_wchar character)