Skip to content

Commit cf817b7

Browse files
committed
Update PluginInfoComponent to perform UI updates on message thread
1 parent ab2f3b3 commit cf817b7

2 files changed

Lines changed: 26 additions & 24 deletions

File tree

Source/UI/PluginInstaller.cpp

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ void PluginListBoxComponent::run()
670670
pluginName = pluginData[i].getProperty ("name", var()).toString();
671671
label = pluginData[i].getProperty ("type", "NULL").toString();
672672
dispName = pluginData[i].getProperty ("display_name", "NULL").toString();
673-
673+
674674
pluginTextWidth = GlyphArrangement::getStringWidthInt (Font (listFont), dispName);
675675
if (pluginTextWidth > maxTextWidth)
676676
maxTextWidth = pluginTextWidth;
@@ -977,10 +977,28 @@ void PluginInfoComponent::setDownloadURL (const String& url)
977977

978978
void PluginInfoComponent::showAlertOnMessageThread (MessageBoxIconType iconType, const String& title, const String& message)
979979
{
980-
MessageManager::callAsync ([iconType, title, message]()
980+
MessageManager::callAsync ([=]()
981981
{ AlertWindow::showMessageBoxAsync (iconType, title, message); });
982982
}
983983

984+
void PluginInfoComponent::updateUIOnMessageThread()
985+
{
986+
MessageManager::callAsync ([this]()
987+
{
988+
pInfo.installedVersion = pInfo.selectedVersion;
989+
installedVerText.setText (pInfo.installedVersion, dontSendNotification);
990+
downloadButton.setEnabled (false);
991+
downloadButton.setButtonText ("Installed");
992+
uninstallButton.setVisible (true);
993+
994+
if (pInfo.installedVersion.equalsIgnoreCase (pInfo.latestVersion))
995+
{
996+
updatablePlugins.removeString (pInfo.pluginName);
997+
this->getParentComponent()->resized();
998+
}
999+
});
1000+
}
1001+
9841002
void PluginInfoComponent::run()
9851003
{
9861004
setProgress (-1.0);
@@ -1095,17 +1113,7 @@ void PluginInfoComponent::run()
10951113

10961114
LOGC ("Download Successful!!");
10971115

1098-
pInfo.installedVersion = pInfo.selectedVersion;
1099-
installedVerText.setText (pInfo.installedVersion, dontSendNotification);
1100-
downloadButton.setEnabled (false);
1101-
downloadButton.setButtonText ("Installed");
1102-
uninstallButton.setVisible (true);
1103-
1104-
if (pInfo.latestVersion.equalsIgnoreCase (pInfo.latestVersion))
1105-
{
1106-
updatablePlugins.removeString (pInfo.pluginName);
1107-
this->getParentComponent()->resized();
1108-
}
1116+
updateUIOnMessageThread();
11091117
}
11101118
else if (dlReturnCode == ZIP_NOTFOUND)
11111119
{
@@ -1158,17 +1166,7 @@ void PluginInfoComponent::run()
11581166

11591167
LOGE ("Loading Plugin Failed!!");
11601168

1161-
pInfo.installedVersion = pInfo.selectedVersion;
1162-
1163-
const MessageManagerLock mmLock;
1164-
downloadButton.setEnabled (false);
1165-
downloadButton.setButtonText ("Installed");
1166-
1167-
if (pInfo.latestVersion.equalsIgnoreCase (pInfo.latestVersion))
1168-
{
1169-
updatablePlugins.removeString (pInfo.pluginName);
1170-
this->getParentComponent()->repaint();
1171-
}
1169+
updateUIOnMessageThread();
11721170
}
11731171
else if (dlReturnCode == HTTP_ERR)
11741172
{

Source/UI/PluginInstaller.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,12 @@ class PluginInfoComponent : public Component,
165165

166166
void run() override;
167167

168+
/** Shows the alert message on the message thread **/
168169
void showAlertOnMessageThread (MessageBoxIconType iconType, const String& title, const String& message);
169170

171+
/** Updates the UI on the message thread **/
172+
void updateUIOnMessageThread();
173+
170174
DropShadower infoCompDropShadower { DropShadow (Colours::black.withAlpha (0.5f), 6, { 2, 2 }) };
171175

172176
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginInfoComponent);

0 commit comments

Comments
 (0)