From af0f2419541aa7edccce74267c839b830f14d381 Mon Sep 17 00:00:00 2001
From: Matteo Galiazzo <matteo@maltesenarrazioni.it>
Date: Wed, 14 May 2008 01:40:53 -0700
Subject: don't save rc in SetStyle command if loading the style fails

---
 src/FbCommands.cc | 9 +++++----
 src/FbTk/Theme.cc | 2 ++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index e0d0768..49f727c 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -274,10 +274,11 @@ SetStyleCmd::SetStyleCmd(const string &filename):m_filename(filename) {
 }
 
 void SetStyleCmd::execute() {
-    Fluxbox::instance()->saveStyleFilename(m_filename.c_str());
-    Fluxbox::instance()->save_rc();
-    FbTk::ThemeManager::instance().load(m_filename,
-                                        Fluxbox::instance()->getStyleOverlayFilename());
+    if (FbTk::ThemeManager::instance().load(m_filename,
+        Fluxbox::instance()->getStyleOverlayFilename())) {
+        Fluxbox::instance()->saveStyleFilename(m_filename.c_str());
+        Fluxbox::instance()->save_rc();
+    }
 }
 
 REGISTER_COMMAND_WITH_ARGS(keymode, FbCommands::KeyModeCmd, void);
diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc
index 46c9a56..cd478fc 100644
--- a/src/FbTk/Theme.cc
+++ b/src/FbTk/Theme.cc
@@ -117,6 +117,8 @@ bool ThemeManager::unregisterTheme(Theme &tm) {
 bool ThemeManager::load(const string &filename,
                         const string &overlay_filename, int screen_num) {
     string location = FbTk::StringUtil::expandFilename(filename);
+    StringUtil::removeTrailingWhitespace(location);
+    StringUtil::removeFirstWhitespace(location);
     string prefix = "";
 
     if (FileUtil::isDirectory(filename.c_str())) {
-- 
cgit v0.11.2