@@ -537,16 +537,20 @@ ListBox::~ListBox() | |||||
viewport.reset(); | viewport.reset(); | ||||
} | } | ||||
void ListBox::assignModelPtr (ListBoxModel* const newModel) | |||||
{ | |||||
model = newModel; | |||||
#if ! JUCE_DISABLE_ASSERTIONS | |||||
weakModelPtr = model != nullptr ? model->sharedState : nullptr; | |||||
#endif | |||||
} | |||||
void ListBox::setModel (ListBoxModel* const newModel) | void ListBox::setModel (ListBoxModel* const newModel) | ||||
{ | { | ||||
if (model != newModel) | if (model != newModel) | ||||
{ | { | ||||
model = newModel; | |||||
#if ! JUCE_DISABLE_ASSERTIONS | |||||
weakModelPtr = model != nullptr ? model->sharedState : nullptr; | |||||
#endif | |||||
assignModelPtr (newModel); | |||||
repaint(); | repaint(); | ||||
updateContent(); | updateContent(); | ||||
} | } | ||||
@@ -613,6 +613,7 @@ private: | |||||
std::weak_ptr<ListBoxModel::Empty> weakModelPtr; | std::weak_ptr<ListBoxModel::Empty> weakModelPtr; | ||||
#endif | #endif | ||||
void assignModelPtr (ListBoxModel*); | |||||
void checkModelPtrIsValid() const; | void checkModelPtrIsValid() const; | ||||
std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override; | std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override; | ||||
bool hasAccessibleHeaderComponent() const; | bool hasAccessibleHeaderComponent() const; | ||||
@@ -339,7 +339,7 @@ private: | |||||
TableListBox::TableListBox (const String& name, TableListBoxModel* const m) | TableListBox::TableListBox (const String& name, TableListBoxModel* const m) | ||||
: ListBox (name, nullptr), model (m) | : ListBox (name, nullptr), model (m) | ||||
{ | { | ||||
ListBox::setModel (this); | |||||
ListBox::assignModelPtr (this); | |||||
setHeader (std::make_unique<Header> (*this)); | setHeader (std::make_unique<Header> (*this)); | ||||
} | } | ||||