I’m using a StringArray as a member of a ListBoxModel:
class ArrayListBoxModel : public ListBoxModel
{
protected:
StringArray arr;
ListBox *lb;
public:
ArrayListBoxModel(ListBox *lb = nullptr);
~ArrayListBoxModel();
virtual int getNumRows();
virtual void paintListBoxItem(int rowNum, Graphics &g, int w, int h, bool selected);
void addRow(const String s, bool update=true); // update only used when adding multiple rows
void deleteRow(int rowNum, bool update=true);
void clear();
void setParent(ListBox *lb);
};
When calling arr.add(String("Test Item"))
, there is a segfault at
//==============================================================================
/** Appends a new element at the end of the array.
@param newElement the new object to add to the array
@see set, insert, addIfNotAlreadyThere, addSorted, addUsingDefaultSort, addArray
*/
void add (ParameterType newElement)
{
const ScopedLockType lock (getLock());
data.ensureAllocatedSize (numUsed + 1); // Thread 1 Juce Message Thread: EXC_BAD_ACCESS (code=2, address=0xc)
new (data.elements + numUsed++) ElementType (newElement);
}
I’m on Mac; I got JUCE from git a few days ago. (v2.1.1)