Skip to content

Commit

Permalink
Fix #4966: Reload Models option in Create Model dialog window doesn't…
Browse files Browse the repository at this point in the history
… update the model
  • Loading branch information
codereader committed Mar 10, 2019
1 parent 06e6d35 commit 4f9f5b3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion radiant/map/algorithm/Export.cpp
Expand Up @@ -127,7 +127,7 @@ void exportSelectedAsModel(const ModelExportOptions& options)
Node_getEntity(modelNode)->setKeyValue("model", relativeModelPath);

// It's possible that the export overwrote a model we're already using in this map, refresh it
refreshSelectedModels();
refreshSelectedModels(false);
}
catch (selection::algorithm::EntityCreationException&)
{
Expand Down
22 changes: 16 additions & 6 deletions radiant/map/algorithm/Models.cpp
Expand Up @@ -88,10 +88,15 @@ class ModelRefreshWalker :
}
};

void refreshModels()
void refreshModels(bool blockScreenUpdates)
{
// Disable screen updates for the scope of this function
ui::ScreenUpdateBlocker blocker(_("Processing..."), _("Reloading Models"));
std::unique_ptr<ui::ScreenUpdateBlocker> blocker;

if (blockScreenUpdates)
{
// Disable screen updates for the scope of this function
blocker.reset(new ui::ScreenUpdateBlocker(_("Processing..."), _("Reloading Models")));
}

// Clear the model cache
GlobalModelCache().clear();
Expand All @@ -104,10 +109,15 @@ void refreshModels()
GlobalModelCache().signal_modelsReloaded().emit();
}

void refreshSelectedModels()
void refreshSelectedModels(bool blockScreenUpdates)
{
// Disable screen updates for the scope of this function
ui::ScreenUpdateBlocker blocker(_("Processing..."), _("Reloading Models"));
std::unique_ptr<ui::ScreenUpdateBlocker> blocker;

if (blockScreenUpdates)
{
// Disable screen updates for the scope of this function
blocker.reset(new ui::ScreenUpdateBlocker(_("Processing..."), _("Reloading Models")));
}

// Find all models in the current selection
ModelFinder walker;
Expand Down
4 changes: 2 additions & 2 deletions radiant/map/algorithm/Models.h
Expand Up @@ -7,10 +7,10 @@ namespace algorithm
{

// This reloads all models in the map
void refreshModels();
void refreshModels(bool blockScreenUpdates);

// This reloads all selected models in the map
void refreshSelectedModels();
void refreshSelectedModels(bool blockScreenUpdates);

}

Expand Down
4 changes: 2 additions & 2 deletions radiant/model/ModelCache.cpp
Expand Up @@ -205,12 +205,12 @@ void ModelCache::shutdownModule()

void ModelCache::refreshModels(const cmd::ArgumentList& args)
{
map::algorithm::refreshModels();
map::algorithm::refreshModels(true);
}

void ModelCache::refreshSelectedModels(const cmd::ArgumentList& args)
{
map::algorithm::refreshSelectedModels();
map::algorithm::refreshSelectedModels(true);
}

// The static module
Expand Down
6 changes: 4 additions & 2 deletions radiant/ui/modelselector/ModelSelector.cpp
Expand Up @@ -27,6 +27,8 @@

#include <functional>

#include "map/algorithm/Models.h"

namespace ui
{

Expand Down Expand Up @@ -484,8 +486,8 @@ void ModelSelector::onReloadModels(wxCommandEvent& ev)
// Remember the selected model before reloading
_preselectedModel = getSelectedValue(_columns.vfspath);

_populated = false;
populateModels();
// This will fire the models reloaded signal after some time
map::algorithm::refreshModels(false);
}

void ModelSelector::onReloadSkins(wxCommandEvent& ev)
Expand Down

0 comments on commit 4f9f5b3

Please sign in to comment.