summaryrefslogtreecommitdiff
path: root/glib/glibmm/error.cc
diff options
context:
space:
mode:
Diffstat (limited to 'glib/glibmm/error.cc')
-rw-r--r--glib/glibmm/error.cc40
1 files changed, 19 insertions, 21 deletions
diff --git a/glib/glibmm/error.cc b/glib/glibmm/error.cc
index fe01cc6f..315ea71d 100644
--- a/glib/glibmm/error.cc
+++ b/glib/glibmm/error.cc
@@ -1,5 +1,3 @@
-// -*- c++ -*-
-
/* error.cc
*
* Copyright 2002 The gtkmm Development Team
@@ -21,6 +19,7 @@
#include <glibmmconfig.h>
#include <glibmm/error.h>
+#include <glibmm/wrap.h>
#include <glibmm/wrap_init.h>
#include <glib.h>
#include <map>
@@ -30,7 +29,7 @@ namespace
typedef std::map<GQuark,Glib::Error::ThrowFunc> ThrowFuncTable;
-static ThrowFuncTable* throw_func_table = 0;
+static ThrowFuncTable* throw_func_table = nullptr;
} // anonymous namespace
@@ -43,9 +42,9 @@ Error::Error()
gobject_ (0)
{}
-Error::Error(GQuark domain, int code, const Glib::ustring& message)
+Error::Error(GQuark error_domain, int error_code, const Glib::ustring& message)
:
- gobject_ (g_error_new_literal(domain, code, message.c_str()))
+ gobject_ (g_error_new_literal(error_domain, error_code, message.c_str()))
{}
Error::Error(GError* gobject, bool take_copy)
@@ -66,7 +65,7 @@ Error& Error::operator=(const Error& other)
if(gobject_)
{
g_error_free(gobject_);
- gobject_ = 0;
+ gobject_ = nullptr;
}
if(other.gobject_)
{
@@ -76,7 +75,7 @@ Error& Error::operator=(const Error& other)
return *this;
}
-Error::~Error() throw()
+Error::~Error() noexcept
{
if(gobject_)
g_error_free(gobject_);
@@ -84,29 +83,29 @@ Error::~Error() throw()
GQuark Error::domain() const
{
- g_return_val_if_fail(gobject_ != 0, 0);
+ g_return_val_if_fail(gobject_ != nullptr, 0);
return gobject_->domain;
}
int Error::code() const
{
- g_return_val_if_fail(gobject_ != 0, -1);
+ g_return_val_if_fail(gobject_ != nullptr, -1);
return gobject_->code;
}
Glib::ustring Error::what() const
{
- g_return_val_if_fail(gobject_ != 0, "");
- g_return_val_if_fail(gobject_->message != 0, "");
+ g_return_val_if_fail(gobject_ != nullptr, "");
+ g_return_val_if_fail(gobject_->message != nullptr, "");
return gobject_->message;
}
-bool Error::matches(GQuark domain, int code) const
+bool Error::matches(GQuark error_domain, int error_code) const
{
- return g_error_matches(gobject_, domain, code);
+ return g_error_matches(gobject_, error_domain, error_code);
}
GError* Error::gobj()
@@ -122,7 +121,7 @@ const GError* Error::gobj() const
void Error::propagate(GError** dest)
{
g_propagate_error(dest, gobject_);
- gobject_ = 0;
+ gobject_ = nullptr;
}
// static
@@ -131,6 +130,7 @@ void Error::register_init()
if(!throw_func_table)
{
throw_func_table = new ThrowFuncTable();
+ Glib::wrap_register_init();
Glib::wrap_init(); // make sure that at least the Glib exceptions are registered
}
}
@@ -141,22 +141,22 @@ void Error::register_cleanup()
if(throw_func_table)
{
delete throw_func_table;
- throw_func_table = 0;
+ throw_func_table = nullptr;
}
}
// static
-void Error::register_domain(GQuark domain, Error::ThrowFunc throw_func)
+void Error::register_domain(GQuark error_domain, Error::ThrowFunc throw_func)
{
- g_assert(throw_func_table != 0);
+ g_assert(throw_func_table != nullptr);
- (*throw_func_table)[domain] = throw_func;
+ (*throw_func_table)[error_domain] = throw_func;
}
// static, noreturn
void Error::throw_exception(GError* gobject)
{
- g_assert(gobject != 0);
+ g_assert(gobject != nullptr);
// Just in case Gtk::Main hasn't been instantiated yet.
if(!throw_func_table)
@@ -176,6 +176,4 @@ void Error::throw_exception(GError* gobject)
throw Glib::Error(gobject);
}
-
} // namespace Glib
-