Skip to content

Commit

Permalink
Modified ConfigManager to always return a copy of the internal Config…
Browse files Browse the repository at this point in the history
…urations.
  • Loading branch information
end2endzone committed Dec 28, 2021
1 parent deccf01 commit 01fc6fb
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion include/shellanything/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace shellanything
/// <summary>
/// Get the list of Configuration pointers handled by the manager
/// </summary>
ConfigurationPtrList & GetConfigurations();
ConfigurationPtrList GetConfigurations();

/// <summary>
/// Returns true if the given path is a Configuration loaded by the manager.
Expand Down
14 changes: 7 additions & 7 deletions src/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ namespace shellanything
LOG(INFO) << __FUNCTION__ << "()";

//validate existing configurations
ConfigurationPtrList configs_copy = GetConfigurations();
for(size_t i=0; i< configs_copy.size(); i++)
ConfigurationPtrList configs = GetConfigurations();
for(size_t i=0; i< configs.size(); i++)
{
Configuration * config = configs_copy[i];
Configuration * config = configs[i];

//compare the file's date at the load time and the current date
const std::string & file_path = config->GetFilePath();
Expand Down Expand Up @@ -143,7 +143,7 @@ namespace shellanything
void ConfigManager::Update(const Context & context)
{
//for each child
ConfigurationPtrList & configurations = ConfigManager::GetConfigurations();
ConfigurationPtrList configurations = ConfigManager::GetConfigurations();
for(size_t i=0; i<configurations.size(); i++)
{
Configuration * config = configurations[i];
Expand All @@ -154,7 +154,7 @@ namespace shellanything
Menu * ConfigManager::FindMenuByCommandId(const uint32_t & command_id)
{
//for each child
ConfigurationPtrList & configurations = ConfigManager::GetConfigurations();
ConfigurationPtrList configurations = ConfigManager::GetConfigurations();
for(size_t i=0; i<configurations.size(); i++)
{
Configuration * config = configurations[i];
Expand All @@ -171,7 +171,7 @@ namespace shellanything
uint32_t nextCommandId = first_command_id;

//for each child
ConfigurationPtrList & configurations = ConfigManager::GetConfigurations();
ConfigurationPtrList configurations = ConfigManager::GetConfigurations();
for(size_t i=0; i<configurations.size(); i++)
{
Configuration * config = configurations[i];
Expand All @@ -181,7 +181,7 @@ namespace shellanything
return nextCommandId;
}

ConfigurationPtrList & ConfigManager::GetConfigurations()
ConfigurationPtrList ConfigManager::GetConfigurations()
{
return mConfigurations;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shellext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ void CContextMenu::BuildMenuTree(HMENU hMenu)

//for each configuration
shellanything::ConfigManager & cmgr = shellanything::ConfigManager::GetInstance();
shellanything::ConfigurationPtrList & configs = cmgr.GetConfigurations();
shellanything::ConfigurationPtrList configs = cmgr.GetConfigurations();
UINT insert_pos = 0;
for(size_t i=0; i<configs.size(); i++)
{
Expand Down
14 changes: 7 additions & 7 deletions test/TestConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//Delete the source file of all remaining Configuration instance
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
for(size_t i=0; i<configs.size(); i++)
{
Configuration * config = configs[i];
Expand Down Expand Up @@ -177,7 +177,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//ASSERT a single menu is available
Expand Down Expand Up @@ -232,7 +232,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//ASSERT a single menu is available
Expand Down Expand Up @@ -302,7 +302,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the files are loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 2, configs.size() );

//Assign unique command ids
Expand Down Expand Up @@ -384,7 +384,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//act
Expand Down Expand Up @@ -421,7 +421,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//Query first menu
Expand Down Expand Up @@ -485,7 +485,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//Query all menus
Expand Down
2 changes: 1 addition & 1 deletion test/TestConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//ASSERT that properties was applied
Expand Down
24 changes: 12 additions & 12 deletions test/TestObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//Delete the source file of all remaining Configuration instance
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
for(size_t i=0; i<configs.size(); i++)
{
Configuration * config = configs[i];
Expand Down Expand Up @@ -197,7 +197,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//ASSERT all menus are available
Expand Down Expand Up @@ -289,7 +289,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//ASSERT all 3 menus are available
Expand Down Expand Up @@ -342,7 +342,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//ASSERT all 5 menus are available
Expand Down Expand Up @@ -383,7 +383,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//ASSERT all menus are available
Expand Down Expand Up @@ -447,7 +447,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//ASSERT a 13 menus are available
Expand Down Expand Up @@ -515,7 +515,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//ASSERT a 3 menus are available
Expand Down Expand Up @@ -573,7 +573,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//ASSERT a multiple menus are available
Expand Down Expand Up @@ -649,7 +649,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//ASSERT a multiple menus are available
Expand Down Expand Up @@ -709,7 +709,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//ASSERT a multiple menus are available
Expand Down Expand Up @@ -775,7 +775,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//ASSERT a DefaultSettings section is available
Expand Down Expand Up @@ -822,7 +822,7 @@ namespace shellanything { namespace test
cmgr.Refresh();

//ASSERT the file is loaded
ConfigurationPtrList & configs = cmgr.GetConfigurations();
ConfigurationPtrList configs = cmgr.GetConfigurations();
ASSERT_EQ( 1, configs.size() );

//ASSERT a multiple menus are available
Expand Down

0 comments on commit 01fc6fb

Please sign in to comment.