Fix issue #277, LoadPalette command can change the default palette

This commit is contained in:
David Capello 2013-11-15 17:01:28 -03:00
parent ddf4a13490
commit 49cf2bdcf0
2 changed files with 9 additions and 4 deletions

View File

@ -134,11 +134,14 @@ App::App(int argc, const char* argv[])
RenderEngine::loadConfig();
// Default palette.
if (!options.paletteFileName().empty()) {
const char* palFile = options.paletteFileName().c_str();
PRINTF("Loading custom palette file: %s\n", palFile);
base::string palFile(!options.paletteFileName().empty() ?
options.paletteFileName():
base::string(get_config_string("GfxMode", "Palette", "")));
base::UniquePtr<Palette> pal(Palette::load(palFile));
if (!palFile.empty()) {
PRINTF("Loading custom palette file: %s\n", palFile.c_str());
base::UniquePtr<Palette> pal(Palette::load(palFile.c_str()));
if (pal.get() == NULL)
throw base::Exception("Error loading default palette from: %s", palFile);

View File

@ -24,6 +24,7 @@
#include "app/context_access.h"
#include "app/document_api.h"
#include "app/file_selector.h"
#include "app/ini_file.h"
#include "app/modules/palettes.h"
#include "app/undo_transaction.h"
#include "base/compiler_specific.h"
@ -70,6 +71,7 @@ void LoadPaletteCommand::onExecute(Context* context)
}
else {
set_default_palette(palette);
set_config_string("GfxMode", "Palette", filename.c_str());
}
// Set the palette calling the hooks