mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-24 01:54:22 +00:00
Message leak fix. Android repaint fix. Minor clean-ups.
This commit is contained in:
parent
f80d119614
commit
87d3acf19f
9 changed files with 52 additions and 79 deletions
|
|
@ -169,8 +169,8 @@ private:
|
|||
|
||||
static VstEvent* allocateVSTEvent()
|
||||
{
|
||||
VstEvent* const e = (VstEvent*) ::calloc (1, sizeof (VstMidiEvent) > sizeof (VstMidiSysexEvent) ? sizeof (VstMidiEvent)
|
||||
: sizeof (VstMidiSysexEvent));
|
||||
VstEvent* const e = (VstEvent*) std::calloc (1, sizeof (VstMidiEvent) > sizeof (VstMidiSysexEvent) ? sizeof (VstMidiEvent)
|
||||
: sizeof (VstMidiSysexEvent));
|
||||
e->type = kVstMidiType;
|
||||
e->byteSize = sizeof (VstMidiEvent);
|
||||
return e;
|
||||
|
|
@ -181,7 +181,7 @@ private:
|
|||
if (e->type == kVstSysExType)
|
||||
delete[] (((VstMidiSysexEvent*) e)->sysexDump);
|
||||
|
||||
::free (e);
|
||||
std::free (e);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public:
|
|||
If you want an array of zero values, you can use the calloc() method instead.
|
||||
*/
|
||||
explicit HeapBlock (const size_t numElements)
|
||||
: data (static_cast <ElementType*> (::malloc (numElements * sizeof (ElementType))))
|
||||
: data (static_cast <ElementType*> (std::malloc (numElements * sizeof (ElementType))))
|
||||
{
|
||||
throwOnAllocationFailure();
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ public:
|
|||
*/
|
||||
~HeapBlock()
|
||||
{
|
||||
::free (data);
|
||||
std::free (data);
|
||||
}
|
||||
|
||||
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
|
||||
|
|
@ -203,8 +203,8 @@ public:
|
|||
*/
|
||||
void malloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
|
||||
{
|
||||
::free (data);
|
||||
data = static_cast <ElementType*> (::malloc (newNumElements * elementSize));
|
||||
std::free (data);
|
||||
data = static_cast <ElementType*> (std::malloc (newNumElements * elementSize));
|
||||
throwOnAllocationFailure();
|
||||
}
|
||||
|
||||
|
|
@ -213,8 +213,8 @@ public:
|
|||
*/
|
||||
void calloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
|
||||
{
|
||||
::free (data);
|
||||
data = static_cast <ElementType*> (::calloc (newNumElements, elementSize));
|
||||
std::free (data);
|
||||
data = static_cast <ElementType*> (std::calloc (newNumElements, elementSize));
|
||||
throwOnAllocationFailure();
|
||||
}
|
||||
|
||||
|
|
@ -224,12 +224,12 @@ public:
|
|||
*/
|
||||
void allocate (const size_t newNumElements, const bool initialiseToZero)
|
||||
{
|
||||
::free (data);
|
||||
std::free (data);
|
||||
|
||||
if (initialiseToZero)
|
||||
data = static_cast <ElementType*> (::calloc (newNumElements, sizeof (ElementType)));
|
||||
data = static_cast <ElementType*> (std::calloc (newNumElements, sizeof (ElementType)));
|
||||
else
|
||||
data = static_cast <ElementType*> (::malloc (newNumElements * sizeof (ElementType)));
|
||||
data = static_cast <ElementType*> (std::malloc (newNumElements * sizeof (ElementType)));
|
||||
|
||||
throwOnAllocationFailure();
|
||||
}
|
||||
|
|
@ -242,9 +242,9 @@ public:
|
|||
void realloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
|
||||
{
|
||||
if (data == nullptr)
|
||||
data = static_cast <ElementType*> (::malloc (newNumElements * elementSize));
|
||||
data = static_cast <ElementType*> (std::malloc (newNumElements * elementSize));
|
||||
else
|
||||
data = static_cast <ElementType*> (::realloc (data, newNumElements * elementSize));
|
||||
data = static_cast <ElementType*> (std::realloc (data, newNumElements * elementSize));
|
||||
|
||||
throwOnAllocationFailure();
|
||||
}
|
||||
|
|
@ -254,7 +254,7 @@ public:
|
|||
*/
|
||||
void free()
|
||||
{
|
||||
::free (data);
|
||||
std::free (data);
|
||||
data = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ template <typename JavaType>
|
|||
class LocalRef
|
||||
{
|
||||
public:
|
||||
explicit inline LocalRef (JavaType obj_) noexcept : obj (obj_){}
|
||||
explicit inline LocalRef (JavaType obj_) noexcept : obj (obj_) {}
|
||||
inline LocalRef (const LocalRef& other) noexcept : obj (retain (other.obj)) {}
|
||||
~LocalRef() { clear(); }
|
||||
|
||||
|
|
@ -143,8 +143,7 @@ namespace
|
|||
{
|
||||
String juceString (JNIEnv* env, jstring s)
|
||||
{
|
||||
jboolean isCopy;
|
||||
const char* const utf8 = env->GetStringUTFChars (s, &isCopy);
|
||||
const char* const utf8 = env->GetStringUTFChars (s, nullptr);
|
||||
CharPointer_UTF8 utf8CP (utf8);
|
||||
const String result (utf8CP);
|
||||
env->ReleaseStringUTFChars (s, utf8);
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ void Logger::outputDebugString (const String& text)
|
|||
|
||||
//==============================================================================
|
||||
#ifdef JUCE_DLL
|
||||
JUCE_API void* juceDLL_malloc (size_t sz) { return ::malloc (sz); }
|
||||
JUCE_API void juceDLL_free (void* block) { ::free (block); }
|
||||
JUCE_API void* juceDLL_malloc (size_t sz) { return std::malloc (sz); }
|
||||
JUCE_API void juceDLL_free (void* block) { std::free (block); }
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -104,7 +104,6 @@
|
|||
#endif
|
||||
|
||||
#if JUCE_MSVC
|
||||
#include <malloc.h>
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ void MessageManager::runDispatchLoop()
|
|||
void MessageManager::stopDispatchLoop()
|
||||
{
|
||||
(new QuitMessage())->post();
|
||||
quitMessagePosted = true;
|
||||
}
|
||||
|
||||
bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
|
||||
|
|
|
|||
|
|
@ -50,12 +50,12 @@ namespace pnglibNamespace
|
|||
#if JUCE_INCLUDE_PNGLIB_CODE || ! defined (JUCE_INCLUDE_PNGLIB_CODE)
|
||||
|
||||
#if _MSC_VER != 1310
|
||||
using ::calloc; // (causes conflict in VS.NET 2003)
|
||||
using ::malloc;
|
||||
using ::free;
|
||||
using std::calloc; // (causes conflict in VS.NET 2003)
|
||||
using std::malloc;
|
||||
using std::free;
|
||||
#endif
|
||||
|
||||
using ::abs;
|
||||
using std::abs;
|
||||
#define PNG_INTERNAL
|
||||
#define NO_DUMMY_DECL
|
||||
#define PNG_SETJMP_NOT_SUPPORTED
|
||||
|
|
@ -95,10 +95,6 @@ namespace pnglibNamespace
|
|||
#pragma warning (pop)
|
||||
#endif
|
||||
|
||||
using ::calloc;
|
||||
using ::malloc;
|
||||
using ::free;
|
||||
|
||||
//==============================================================================
|
||||
namespace PNGHelpers
|
||||
{
|
||||
|
|
|
|||
|
|
@ -180,28 +180,30 @@ public:
|
|||
|
||||
const Rectangle<int> bounds (left, top, right - left, bottom - top);
|
||||
|
||||
if (bounds.isEmpty())
|
||||
return nullptr;
|
||||
EdgeTable* et = nullptr;
|
||||
|
||||
jint* const maskDataElements = env->GetIntArrayElements (maskData, 0);
|
||||
|
||||
EdgeTable* et = new EdgeTable (bounds);
|
||||
|
||||
const jint* mask = maskDataElements;
|
||||
|
||||
for (int y = top; y < bottom; ++y)
|
||||
if (! bounds.isEmpty())
|
||||
{
|
||||
#if JUCE_LITTLE_ENDIAN
|
||||
const uint8* const lineBytes = ((const uint8*) mask) + 3;
|
||||
#else
|
||||
const uint8* const lineBytes = (const uint8*) mask;
|
||||
#endif
|
||||
et = new EdgeTable (bounds);
|
||||
|
||||
et->clipLineToMask (left, y, lineBytes, 4, bounds.getWidth());
|
||||
mask += bounds.getWidth();
|
||||
jint* const maskDataElements = env->GetIntArrayElements (maskData, 0);
|
||||
const jint* mask = maskDataElements;
|
||||
|
||||
for (int y = top; y < bottom; ++y)
|
||||
{
|
||||
#if JUCE_LITTLE_ENDIAN
|
||||
const uint8* const lineBytes = ((const uint8*) mask) + 3;
|
||||
#else
|
||||
const uint8* const lineBytes = (const uint8*) mask;
|
||||
#endif
|
||||
|
||||
et->clipLineToMask (left, y, lineBytes, 4, bounds.getWidth());
|
||||
mask += bounds.getWidth();
|
||||
}
|
||||
|
||||
env->ReleaseIntArrayElements (maskData, maskDataElements, 0);
|
||||
}
|
||||
|
||||
env->ReleaseIntArrayElements (maskData, maskDataElements, 0);
|
||||
env->DeleteLocalRef (maskData);
|
||||
return et;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, launchApp, void, (JNIEnv* en
|
|||
JUCEApplication* app = dynamic_cast <JUCEApplication*> (JUCEApplicationBase::createInstance());
|
||||
if (! app->initialiseApp (String::empty))
|
||||
exit (0);
|
||||
|
||||
jassert (MessageManager::getInstance()->isThisTheMessageThread());
|
||||
}
|
||||
|
||||
JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, quitApp, void, (JNIEnv* env, jobject activity))
|
||||
|
|
@ -386,7 +388,7 @@ public:
|
|||
|
||||
jint* dest = env->GetIntArrayElements ((jintArray) buffer.get(), 0);
|
||||
|
||||
if (dest != 0)
|
||||
if (dest != nullptr)
|
||||
{
|
||||
{
|
||||
Image temp (new PreallocatedImage (clip.getWidth(), clip.getHeight(),
|
||||
|
|
@ -415,26 +417,23 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
class ViewRepainter : public CallbackMessage
|
||||
struct ViewRepainter : public CallbackMessage
|
||||
{
|
||||
public:
|
||||
ViewRepainter (const GlobalRef& view_, const Rectangle<int>& area_)
|
||||
: view (view_), area (area_)
|
||||
{
|
||||
post();
|
||||
}
|
||||
: view (view_), area (area_) {}
|
||||
|
||||
void messageCallback()
|
||||
{
|
||||
view.callVoidMethod (ComponentPeerView.invalidate, area.getX(), area.getY(), area.getRight(), area.getBottom());
|
||||
view.callVoidMethod (ComponentPeerView.invalidate, area.getX(), area.getY(),
|
||||
area.getRight(), area.getBottom());
|
||||
}
|
||||
|
||||
private:
|
||||
GlobalRef view;
|
||||
const Rectangle<int>& area;
|
||||
const Rectangle<int> area;
|
||||
};
|
||||
|
||||
new ViewRepainter (view, area);
|
||||
(new ViewRepainter (view, area))->post();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -448,29 +447,6 @@ public:
|
|||
// TODO
|
||||
}
|
||||
|
||||
#if USE_ANDROID_CANVAS
|
||||
StringArray getAvailableRenderingEngines()
|
||||
{
|
||||
StringArray s (ComponentPeer::getAvailableRenderingEngines());
|
||||
s.add ("Android Canvas Renderer");
|
||||
return s;
|
||||
}
|
||||
|
||||
int getCurrentRenderingEngine() const
|
||||
{
|
||||
return usingAndroidGraphics ? 1 : 0;
|
||||
}
|
||||
|
||||
void setCurrentRenderingEngine (int index)
|
||||
{
|
||||
if (usingAndroidGraphics != (index > 0))
|
||||
{
|
||||
usingAndroidGraphics = index > 0;
|
||||
component->repaint();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
static AndroidComponentPeer* findPeerForJavaView (JNIEnv* env, jobject viewToFind)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue