summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b50bd40)
raw | patch | inline | side by side (parent: b50bd40)
author | joncruz <joncruz@users.sourceforge.net> | |
Mon, 4 May 2009 05:20:54 +0000 (05:20 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Mon, 4 May 2009 05:20:54 +0000 (05:20 +0000) |
index c0501389fafd5f6d7934188c704be6792c2d61ac..49010efdc50dae1291859edfd523471bf9736811 100644 (file)
sp_object_type_register ("sodipodi:namedview", SP_TYPE_NAMEDVIEW);
sp_object_type_register ("sodipodi:guide", SP_TYPE_GUIDE);
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->load(true, false);
+ Inkscape::Preferences::get(); // Ensure preferences are loaded
}
bool
diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index 5d9e217a82f4061fdb43813db9a882b43730be49..abfffefc2599965a14d8bd77bd20f4fe57e8e801 100644 (file)
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
InkErrorHandler* handler = new InkErrorHandler(use_gui);
prefs->setErrorHandler(handler);
+ {
+ Glib::ustring msg;
+ Glib::ustring secondary;
+ if (prefs->getLastError( msg, secondary )) {
+ handler->handleError(msg, secondary);
+ }
+ }
inkscape_load_menus(inkscape);
sp_input_load_from_preferences();
diff --git a/src/inkview.cpp b/src/inkview.cpp
index cd9d5524bdcd1376dc3d77ad479a0185eef1b06b..5cfde2c814a793d1365d32549300ff58394f4902 100644 (file)
--- a/src/inkview.cpp
+++ b/src/inkview.cpp
LIBXML_TEST_VERSION
Inkscape::GC::init();
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Inkscape::Preferences::get(); // ensure preferences are initialized
gtk_init (&argc, (char ***) &argv);
diff --git a/src/preferences.cpp b/src/preferences.cpp
index a6409b5ba4e6d226939f69d2697831a939240a03..071dbf91e2ec69119572c586027b065696c1feb5 100644 (file)
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
_prefs_filename(""),
_prefs_doc(0),
_errorHandler(0),
- _writable(false)
+ _writable(false),
+ _hasError(false)
{
// profile_path essentailly returns the argument prefixed by the profile directory.
gchar *path = profile_path(NULL);
sp_repr_save_file(_prefs_doc, utf8name.data());
}
+bool Preferences::getLastError( Glib::ustring& primary, Glib::ustring& secondary )
+{
+ bool result = _hasError;
+ if ( _hasError ) {
+ primary = _lastErrPrimary;
+ secondary = _lastErrSecondary;
+ _hasError = false;
+ _lastErrPrimary.clear();
+ _lastErrSecondary.clear();
+ } else {
+ primary.clear();
+ secondary.clear();
+ }
+ return result;
+}
// Now for the meat.
@@ -610,6 +626,9 @@ void Preferences::_keySplit(Glib::ustring const &pref_path, Glib::ustring &node_
void Preferences::_reportError(Glib::ustring const &msg, Glib::ustring const &secondary)
{
+ _hasError = true;
+ _lastErrPrimary = msg;
+ _lastErrSecondary = secondary;
if (_errorHandler) {
_errorHandler->handleError(msg, secondary);
}
diff --git a/src/preferences.h b/src/preferences.h
index 3c25a520fdd9eb8bb3228a5e92458adac7225832..7aded5a03cb82603c3c65400bdd30b2776c25232 100644 (file)
--- a/src/preferences.h
+++ b/src/preferences.h
bool isWritable() { return _writable; }
/*@}*/
+ /**
+ * @brief Return details of the last encountered error, if any.
+ *
+ * This method will return true if an error has been encountered, and fill
+ * in the primary and secondary error strings of the last error. If an error
+ * had been encountered, this will reset it.
+ *
+ * @param string to set to the primary error message.
+ * @param string to set to the secondary error message.
+ *
+ * @return True if an error has occurred since last checking, false otherwise.
+ */
+ bool getLastError( Glib::ustring& primary, Glib::ustring& secondary );
+
/**
* @name Iterate over directories and entries.
* @{
std::string _prefs_basename; ///< Basename of the prefs file
std::string _prefs_dir; ///< Directory in which to look for the prefs file
std::string _prefs_filename; ///< Full filename (with directory) of the prefs file
+ Glib::ustring _lastErrPrimary; ///< Last primary error message, if any.
+ Glib::ustring _lastErrSecondary; ///< Last secondary error message, if any.
XML::Document *_prefs_doc; ///< XML document storing all the preferences
ErrorReporter* _errorHandler; ///< Pointer to object reporting errors.
bool _writable; ///< Will the preferences be saved at exit?
+ bool _hasError; ///< Indication that some error has occurred;
/// Wrapper class for XML node observers
class PrefNodeObserver;