Remove all conditional compilation w.r.t. disabling exceptions in Glib since that is no longer supported anyway.

This commit is contained in:
Adam Reichold
2015-12-28 21:01:09 +01:00
parent ff616eb473
commit 5006fb6b27
4 changed files with 5 additions and 104 deletions

View File

@@ -21,10 +21,6 @@
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include "safegtk.h" #include "safegtk.h"
#ifndef GLIBMM_EXCEPTIONS_ENABLED
#include <memory>
#endif
using namespace rtengine; using namespace rtengine;
extern "C" IptcData *iptc_data_new_from_jpeg_file (FILE* infile); extern "C" IptcData *iptc_data_new_from_jpeg_file (FILE* infile);

View File

@@ -76,23 +76,18 @@ Cairo::RefPtr<Cairo::ImageSurface> safe_create_from_png(const Glib::ustring& fil
Glib::RefPtr<Gio::FileInfo> safe_query_file_info (Glib::RefPtr<Gio::File> &file) Glib::RefPtr<Gio::FileInfo> safe_query_file_info (Glib::RefPtr<Gio::File> &file)
{ {
Glib::RefPtr<Gio::FileInfo> info; Glib::RefPtr<Gio::FileInfo> info;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try { try {
info = file->query_info(); info = file->query_info();
} catch (...) { } } catch (...) { }
#else
std::auto_ptr<Glib::Error> error;
info = file->query_info("*", Gio::FILE_QUERY_INFO_NONE, error);
#endif
return info; return info;
} }
Glib::RefPtr<Gio::FileInfo> safe_next_file (Glib::RefPtr<Gio::FileEnumerator> &dirList) Glib::RefPtr<Gio::FileInfo> safe_next_file (Glib::RefPtr<Gio::FileEnumerator> &dirList)
{ {
Glib::RefPtr<Gio::FileInfo> info; Glib::RefPtr<Gio::FileInfo> info;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool retry; bool retry;
Glib::ustring last_error = ""; Glib::ustring last_error = "";
@@ -113,42 +108,15 @@ Glib::RefPtr<Gio::FileInfo> safe_next_file (Glib::RefPtr<Gio::FileEnumerator> &d
} }
} while (retry); } while (retry);
#else
bool retry;
Glib::ustring last_error = "";
do {
retry = false;
std::auto_ptr<Glib::Error> error;
Glib::RefPtr<Gio::Cancellable> cancellable;
info = dirList->next_file(cancellable, error);
if (!info && error.get()) {
printf ("%s\n", error.what().c_str());
retry = (error.what() != last_error);
last_error = error.what();
}
} while (retry);
#endif
return info; return info;
} }
#ifdef GLIBMM_EXCEPTIONS_ENABLED
# define SAFE_ENUMERATOR_CODE_START \ # define SAFE_ENUMERATOR_CODE_START \
do{try { if ((dirList = dir->enumerate_children ())) \ do{try { if ((dirList = dir->enumerate_children ())) \
for (Glib::RefPtr<Gio::FileInfo> info = safe_next_file(dirList); info; info = safe_next_file(dirList)) { for (Glib::RefPtr<Gio::FileInfo> info = safe_next_file(dirList); info; info = safe_next_file(dirList)) {
# define SAFE_ENUMERATOR_CODE_END \ # define SAFE_ENUMERATOR_CODE_END \
}} catch (Glib::Exception& ex) { printf ("%s\n", ex.what().c_str()); }}while(0) }} catch (Glib::Exception& ex) { printf ("%s\n", ex.what().c_str()); }}while(0)
#else
# define SAFE_ENUMERATOR_CODE_START \
do{std::auto_ptr<Glib::Error> error; Glib::RefPtr<Gio::Cancellable> cancellable; \
if ((dirList = dir->enumerate_children (cancellable, "*", Gio::FILE_QUERY_INFO_NONE, error))) \
for (Glib::RefPtr<Gio::FileInfo> info = safe_next_file(dirList); info; info = safe_next_file(dirList)) {
# define SAFE_ENUMERATOR_CODE_END } if (error.get()) printf ("%s\n", error->what().c_str());}while (0)
#endif
/* /*
* safe_build_file_list can now filter out at the source all files that doesn't have the extensions specified (if provided) * safe_build_file_list can now filter out at the source all files that doesn't have the extensions specified (if provided)
@@ -223,8 +191,8 @@ void safe_build_subdir_list (Glib::RefPtr<Gio::File> &dir, std::vector<Glib::ust
Glib::ustring safe_filename_to_utf8 (const std::string& src) Glib::ustring safe_filename_to_utf8 (const std::string& src)
{ {
Glib::ustring utf8_str; Glib::ustring utf8_str;
#ifdef WIN32 #ifdef WIN32
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try { try {
utf8_str = Glib::locale_to_utf8(src); utf8_str = Glib::locale_to_utf8(src);
@@ -233,25 +201,17 @@ Glib::ustring safe_filename_to_utf8 (const std::string& src)
} }
#else #else
{
std::auto_ptr<Glib::Error> error;
utf8_str = locale_to_utf8(src, error);
if (error.get()) {
utf8_str = Glib::convert_with_fallback(src, "UTF-8", "ISO-8859-1", "?", error);
}
}
#endif //GLIBMM_EXCEPTIONS_ENABLED
#else
utf8_str = Glib::filename_to_utf8(src); utf8_str = Glib::filename_to_utf8(src);
#endif #endif
return utf8_str; return utf8_str;
} }
Glib::ustring safe_locale_to_utf8 (const std::string& src) Glib::ustring safe_locale_to_utf8 (const std::string& src)
{ {
Glib::ustring utf8_str; Glib::ustring utf8_str;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try { try {
utf8_str = Glib::locale_to_utf8(src); utf8_str = Glib::locale_to_utf8(src);
@@ -259,38 +219,17 @@ Glib::ustring safe_locale_to_utf8 (const std::string& src)
utf8_str = Glib::convert_with_fallback(src, "UTF-8", "ISO-8859-1", "?"); utf8_str = Glib::convert_with_fallback(src, "UTF-8", "ISO-8859-1", "?");
} }
#else
{
std::auto_ptr<Glib::Error> error;
utf8_str = locale_to_utf8(src, error);
if (error.get()) {
utf8_str = Glib::convert_with_fallback(src, "UTF-8", "ISO-8859-1", "?", error);
}
}
#endif //GLIBMM_EXCEPTIONS_ENABLED
return utf8_str; return utf8_str;
} }
std::string safe_locale_from_utf8 (const Glib::ustring& utf8_str) std::string safe_locale_from_utf8 (const Glib::ustring& utf8_str)
{ {
std::string str; std::string str;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try { try {
str = Glib::locale_from_utf8(utf8_str); str = Glib::locale_from_utf8(utf8_str);
} catch (const Glib::Error& e) { } catch (Glib::Error&) {}
//str = Glib::convert_with_fallback(utf8_str, "ISO-8859-1", "UTF-8", "?");
}
#else
{
std::auto_ptr<Glib::Error> error;
str = Glib::locale_from_utf8(utf8_str, error);
/*if (error.get())
{str = Glib::convert_with_fallback(utf8_str, "ISO-8859-1", "UTF-8", "?", error);}*/
}
#endif //GLIBMM_EXCEPTIONS_ENABLED
return str; return str;
} }
@@ -298,7 +237,6 @@ bool safe_spawn_command_line_async (const Glib::ustring& cmd_utf8)
{ {
std::string cmd; std::string cmd;
bool success = false; bool success = false;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try { try {
cmd = Glib::filename_from_utf8(cmd_utf8); cmd = Glib::filename_from_utf8(cmd_utf8);
@@ -309,22 +247,6 @@ bool safe_spawn_command_line_async (const Glib::ustring& cmd_utf8)
printf ("%s\n", ex.what().c_str()); printf ("%s\n", ex.what().c_str());
} }
#else
std::auto_ptr<Glib::Error> error;
cmd = Glib::filename_from_utf8(cmd_utf8, error);
if (!error.get()) {
printf ("command line: %s\n", cmd.c_str());
Glib::spawn_command_line_async (cmd, error);
}
if (error.get()) {
printf ("%s\n", error->what().c_str());
} else {
success = true;
}
#endif
return success; return success;
} }

View File

@@ -61,20 +61,12 @@ EditWindow::EditWindow (RTWindow* p) : parent(p) , isFullscreen(false)
Glib::ustring fName = "rt-logo.png"; Glib::ustring fName = "rt-logo.png";
Glib::ustring fullPath = RTImage::findIconAbsolutePath(fName); Glib::ustring fullPath = RTImage::findIconAbsolutePath(fName);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try { try {
set_default_icon_from_file (fullPath); set_default_icon_from_file (fullPath);
} catch(Glib::Exception& ex) { } catch(Glib::Exception& ex) {
printf ("%s\n", ex.what().c_str()); printf ("%s\n", ex.what().c_str());
} }
#else
{
std::auto_ptr<Glib::Error> error;
set_default_icon_from_file (fullPath, error);
}
#endif //GLIBMM_EXCEPTIONS_ENABLED
set_title_decorated(""); set_title_decorated("");
property_allow_shrink() = true; property_allow_shrink() = true;
set_modal(false); set_modal(false);

View File

@@ -94,21 +94,12 @@ RTWindow::RTWindow ()
Glib::ustring fName = "rt-logo.png"; Glib::ustring fName = "rt-logo.png";
Glib::ustring fullPath = RTImage::findIconAbsolutePath(fName); Glib::ustring fullPath = RTImage::findIconAbsolutePath(fName);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try { try {
set_default_icon_from_file (fullPath); set_default_icon_from_file (fullPath);
} catch(Glib::Exception& ex) { } catch(Glib::Exception& ex) {
printf ("%s\n", ex.what().c_str()); printf ("%s\n", ex.what().c_str());
} }
#else
{
std::auto_ptr<Glib::Error> error;
set_default_icon_from_file (fullPath, error);
}
#endif //GLIBMM_EXCEPTIONS_ENABLED
#if defined(__APPLE__) #if defined(__APPLE__)
{ {
osxApp = (GtkosxApplication *)g_object_new (GTKOSX_TYPE_APPLICATION, NULL); osxApp = (GtkosxApplication *)g_object_new (GTKOSX_TYPE_APPLICATION, NULL);