summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2007-11-17 23:52:33 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2007-11-17 23:52:33 +0000
commit677739f03f65d5f9fa59df15b7306e9dbebc7fbe (patch)
tree5a8dc3dcc6a6d3fa661e77c2c839af13cd2f1e28 /src
parentMerged from Poppler's Gfx.cc; Unset the font if it doesn't exist or we can no... (diff)
downloadinkscape-677739f03f65d5f9fa59df15b7306e9dbebc7fbe.tar.gz
inkscape-677739f03f65d5f9fa59df15b7306e9dbebc7fbe.zip
Fix exception catching, to allow polymorphism. Note to all: always catch by reference! 17.7 of C++FAQlite
(bzr r4099)
Diffstat (limited to 'src')
-rw-r--r--src/2geom/exception.h13
-rw-r--r--src/live_effects/effect.cpp2
-rw-r--r--src/ui/dialog/filedialogimpl-gtkmm.cpp4
3 files changed, 8 insertions, 11 deletions
diff --git a/src/2geom/exception.h b/src/2geom/exception.h
index bd950726f..1a031cab9 100644
--- a/src/2geom/exception.h
+++ b/src/2geom/exception.h
@@ -31,6 +31,7 @@
*/
#include <exception>
+#include <sstream>
#include <string>
namespace Geom {
@@ -39,19 +40,15 @@ namespace Geom {
class Exception : public std::exception {
public:
Exception(const char * message, const char *file, const int line)
- : msgstr("Exception thrown: ")
{
- msgstr += message;
- msgstr += " (";
- msgstr += file;
- msgstr += ":";
- msgstr += line;
- msgstr += ")";
+ std::ostringstream os;
+ os << "lib2geom exception: " << message << " (" << file << ":" << line << ")";
+ msgstr = os.str();
}
virtual ~Exception() throw() {} // necessary to destroy the string object!!!
- virtual const char * what() const throw (){
+ virtual const char* what() const throw (){
return msgstr.c_str();
}
protected:
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 4ccfa5952..8b0a2f62a 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -144,7 +144,7 @@ Effect::doEffect_nartbpath (NArtBpath * path_in)
return new_bpath;
}
- catch (std::exception e) {
+ catch (std::exception & e) {
g_warning("Exception during LPE %s execution. \n %s", getName().c_str(), e.what());
SP_ACTIVE_DESKTOP->messageStack()->flash( Inkscape::WARNING_MESSAGE,
_("An exception occurred during execution of the Path Effect.") );
diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp
index b47e26d12..5dd8e66f2 100644
--- a/src/ui/dialog/filedialogimpl-gtkmm.cpp
+++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp
@@ -209,12 +209,12 @@ void SVGPreview::showImage(Glib::ustring &theFileName)
try {
img = Gdk::Pixbuf::create_from_file(fileName);
}
- catch (Glib::FileError e)
+ catch (Glib::FileError & e)
{
g_message("caught Glib::FileError in SVGPreview::showImage");
return;
}
- catch (Gdk::PixbufError e)
+ catch (Gdk::PixbufError & e)
{
g_message("Gdk::PixbufError in SVGPreview::showImage");
return;