mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-12 09:30:22 -07:00
Avoid crashing when enabling/disable/installing/deleting
This commit is contained in:
parent
07e5fb08b3
commit
50e03baea7
1 changed files with 15 additions and 6 deletions
|
|
@ -58,6 +58,9 @@ object ReflectiveEditorView : View {
|
||||||
// Store reference to the search field
|
// Store reference to the search field
|
||||||
private var searchField: CustomSearchField? = null
|
private var searchField: CustomSearchField? = null
|
||||||
|
|
||||||
|
// Flag for scheduled plugin reload to avoid crashes
|
||||||
|
private var reloadPlugins = false
|
||||||
|
|
||||||
private fun loadCogIcon() {
|
private fun loadCogIcon() {
|
||||||
try {
|
try {
|
||||||
val imageStream = this::class.java.getResourceAsStream("res/cog.png")
|
val imageStream = this::class.java.getResourceAsStream("res/cog.png")
|
||||||
|
|
@ -579,8 +582,8 @@ object ReflectiveEditorView : View {
|
||||||
if (sourceDir.renameTo(destDir)) {
|
if (sourceDir.renameTo(destDir)) {
|
||||||
showToast(mainPanel, "Plugin enabled")
|
showToast(mainPanel, "Plugin enabled")
|
||||||
|
|
||||||
// Reload plugins to apply the change
|
// Schedule plugin reload to avoid crashes
|
||||||
PluginRepository.reloadPlugins()
|
reloadPlugins = true
|
||||||
|
|
||||||
// Refresh the plugin list view
|
// Refresh the plugin list view
|
||||||
SwingUtilities.invokeLater {
|
SwingUtilities.invokeLater {
|
||||||
|
|
@ -661,8 +664,8 @@ object ReflectiveEditorView : View {
|
||||||
if (sourceDir.renameTo(destDir)) {
|
if (sourceDir.renameTo(destDir)) {
|
||||||
showToast(mainPanel, if (activated) "Plugin enabled" else "Plugin disabled")
|
showToast(mainPanel, if (activated) "Plugin enabled" else "Plugin disabled")
|
||||||
|
|
||||||
// Reload plugins to apply the change
|
// Schedule plugin reload to avoid crashes
|
||||||
PluginRepository.reloadPlugins()
|
reloadPlugins = true
|
||||||
|
|
||||||
// Refresh the plugin list view
|
// Refresh the plugin list view
|
||||||
SwingUtilities.invokeLater {
|
SwingUtilities.invokeLater {
|
||||||
|
|
@ -789,6 +792,12 @@ object ReflectiveEditorView : View {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if we need to reload plugins
|
||||||
|
if (reloadPlugins) {
|
||||||
|
PluginRepository.reloadPlugins()
|
||||||
|
reloadPlugins = false
|
||||||
|
}
|
||||||
|
|
||||||
// Update plugin statuses to reflect current loaded plugins
|
// Update plugin statuses to reflect current loaded plugins
|
||||||
updatePluginStatuses()
|
updatePluginStatuses()
|
||||||
|
|
||||||
|
|
@ -1279,9 +1288,9 @@ object ReflectiveEditorView : View {
|
||||||
if (deleteRecursively(pluginDir)) {
|
if (deleteRecursively(pluginDir)) {
|
||||||
showToast(mainPanel, "Plugin deleted successfully", JOptionPane.INFORMATION_MESSAGE)
|
showToast(mainPanel, "Plugin deleted successfully", JOptionPane.INFORMATION_MESSAGE)
|
||||||
|
|
||||||
// If we deleted a loaded plugin, reload plugins
|
// If we deleted a loaded plugin, schedule plugin reload
|
||||||
if (!isDisabled) {
|
if (!isDisabled) {
|
||||||
PluginRepository.reloadPlugins()
|
reloadPlugins = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh the plugin list view
|
// Refresh the plugin list view
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue