|
From: <br...@us...> - 2010-02-14 06:28:25
|
Revision: 4107
http://openvrml.svn.sourceforge.net/openvrml/?rev=4107&view=rev
Author: braden
Date: 2010-02-14 06:28:17 +0000 (Sun, 14 Feb 2010)
Log Message:
-----------
Use Boost.ScopeExit instead of ScopeGuard.
Modified Paths:
--------------
trunk/ChangeLog
trunk/README
trunk/configure-gcc-dbg
trunk/src/libopenvrml/openvrml/browser.cpp
trunk/src/libopenvrml/openvrml/local/conf.cpp
trunk/src/libopenvrml/openvrml/local/error.cpp
trunk/src/libopenvrml/openvrml/local/externproto.cpp
trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp
trunk/src/libopenvrml/openvrml/local/uri.cpp
trunk/src/libopenvrml/openvrml/local/xml_reader.cpp
trunk/src/libopenvrml/openvrml/script.cpp
trunk/src/local/libopenvrml-dl/openvrml/local/dl.cpp
trunk/src/mozilla-plugin/openvrml.cpp
trunk/src/node/vrml97/grouping_node_base.h
trunk/src/node/vrml97/image_stream_listener.cpp
trunk/src/node/vrml97/text.cpp
trunk/src/openvrml-player/curlbrowserhost.cpp
trunk/src/openvrml-player/filechooserdialog.cpp
trunk/src/openvrml-player/player.cpp
trunk/src/openvrml-xembed/browser.cpp
trunk/src/openvrml-xembed/browserfactory.cpp
trunk/src/openvrml-xembed/main.cpp
trunk/src/script/java.cpp
trunk/src/script/javascript.cpp
trunk/tests/browser.cpp
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/ChangeLog 2010-02-14 06:28:17 UTC (rev 4107)
@@ -1,3 +1,31 @@
+2010-02-14 Braden McDaniel <br...@en...>
+
+ Use Boost.ScopeExit instead of ScopeGuard.
+
+ * README: Note Boost 1.38 requirement.
+ * src/libopenvrml/openvrml/browser.cpp
+ * src/libopenvrml/openvrml/local/conf.cpp
+ * src/libopenvrml/openvrml/local/error.cpp
+ * src/libopenvrml/openvrml/local/externproto.cpp
+ * src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp
+ * src/libopenvrml/openvrml/local/uri.cpp
+ * src/libopenvrml/openvrml/local/xml_reader.cpp
+ * src/libopenvrml/openvrml/script.cpp
+ * src/local/libopenvrml-dl/openvrml/local/dl.cpp
+ * src/mozilla-plugin/openvrml.cpp
+ * src/node/vrml97/grouping_node_base.h
+ * src/node/vrml97/image_stream_listener.cpp
+ * src/node/vrml97/text.cpp
+ * src/openvrml-player/curlbrowserhost.cpp
+ * src/openvrml-player/filechooserdialog.cpp
+ * src/openvrml-player/player.cpp
+ * src/openvrml-xembed/browser.cpp
+ * src/openvrml-xembed/browserfactory.cpp
+ * src/openvrml-xembed/main.cpp
+ * src/script/java.cpp
+ * src/script/javascript.cpp
+ * tests/browser.cpp
+
2010-02-13 Braden McDaniel <br...@en...>
Updates for 0.18.4 release.
Modified: trunk/README
===================================================================
--- trunk/README 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/README 2010-02-14 06:28:17 UTC (rev 4107)
@@ -136,7 +136,7 @@
At a minimum, OpenVRML requires these libraries to build:
- Boost (at least 1.37) <http://boost.org>
+ Boost (at least 1.38) <http://boost.org>
libxml (non-Windows only) <http://xmlsoft.org>
These libraries are packaged for many systems; so you should
Modified: trunk/configure-gcc-dbg
===================================================================
--- trunk/configure-gcc-dbg 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/configure-gcc-dbg 2010-02-14 06:28:17 UTC (rev 4107)
@@ -1,3 +1,3 @@
#!/bin/bash
-$(dirname $0)/configure -C --prefix=$HOME --disable-static CXX='g++ -pipe' CPPFLAGS="-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_GLIBCXX_CONCEPT_CHECKS -DG_ERRORCHECK_MUTEXES -I$HOME/include -I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux" CXXFLAGS='-g3 -O0 -pedantic-errors -Wall -Wextra -Wno-missing-braces -Wno-missing-field-initializers -Wno-long-long' LDFLAGS="-L$HOME/lib64 -L$HOME/lib" JRE_HOME=/usr/lib/jvm/jre "$*"
+$(dirname $0)/configure -C --prefix=$HOME --disable-static CXX='g++ -pipe' CPPFLAGS="-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_GLIBCXX_CONCEPT_CHECKS -DG_ERRORCHECK_MUTEXES -I$HOME/include -I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux" CXXFLAGS='-g3 -O0 -Wall -Wextra -Wno-missing-braces -Wno-missing-field-initializers -Wno-long-long' LDFLAGS="-L$HOME/lib64 -L$HOME/lib" JRE_HOME=/usr/lib/jvm/jre "$*"
Modified: trunk/src/libopenvrml/openvrml/browser.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/browser.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/libopenvrml/openvrml/browser.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -3,7 +3,8 @@
// OpenVRML
//
// Copyright 1998 Chris Morley
-// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007 Braden McDaniel
+// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+// Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -32,7 +33,6 @@
# include <boost/function.hpp>
# include <boost/functional.hpp>
# include <boost/lexical_cast.hpp>
-# include <boost/multi_index/detail/scope_guard.hpp>
# include <algorithm>
# include <functional>
# include <cerrno>
@@ -48,8 +48,6 @@
# include <config.h>
# endif
-using namespace boost::multi_index::detail; // for scope_guard
-
/**
* @file openvrml/browser.h
*
Modified: trunk/src/libopenvrml/openvrml/local/conf.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/local/conf.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/libopenvrml/openvrml/local/conf.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -2,7 +2,7 @@
//
// OpenVRML
//
-// Copyright 2009 Braden McDaniel
+// Copyright 2009, 2010 Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -20,7 +20,6 @@
# include "conf.h"
# include "error.h"
-# include <boost/multi_index/detail/scope_guard.hpp>
# include <boost/ref.hpp>
# include <boost/tokenizer.hpp>
# ifdef _WIN32
@@ -30,8 +29,6 @@
# include <cstdlib>
# endif
-using namespace boost::multi_index::detail; // for scope_guard
-
namespace {
class OPENVRML_LOCAL no_environment_var : public std::runtime_error {
Modified: trunk/src/libopenvrml/openvrml/local/error.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/local/error.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/libopenvrml/openvrml/local/error.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -2,7 +2,7 @@
//
// OpenVRML
//
-// Copyright 2009 Braden McDaniel
+// Copyright 2009, 2010 Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -19,21 +19,17 @@
//
# include "error.h"
-# include <boost/multi_index/detail/scope_guard.hpp>
-# include <boost/ref.hpp>
+# include <boost/scope_exit.hpp>
-using namespace boost::multi_index::detail; // for scope_guard
-
-
# ifdef _WIN32
void openvrml::local::throw_runtime_error_from_win32_system_error(LONG result)
OPENVRML_THROW1(std::runtime_error)
{
- using boost::ref;
-
static const LPCVOID source;
LPTSTR buf = 0;
- scope_guard buf_guard = make_guard(LocalFree, ref(buf));
+ BOOST_SCOPE_EXIT((&buf)) {
+ LocalFree(buf);
+ } BOOST_SCOPE_EXIT_END
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ALLOCATE_BUFFER,
source,
Modified: trunk/src/libopenvrml/openvrml/local/externproto.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/local/externproto.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/libopenvrml/openvrml/local/externproto.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -2,7 +2,7 @@
//
// OpenVRML
//
-// Copyright 2009 Braden McDaniel
+// Copyright 2009, 2010 Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -25,10 +25,8 @@
# include <openvrml/scene.h>
# include <boost/function.hpp>
# include <boost/mpl/for_each.hpp>
-# include <boost/multi_index/detail/scope_guard.hpp>
+# include <boost/scope_exit.hpp>
-using namespace boost::multi_index::detail; // for scope_guard
-
struct OPENVRML_LOCAL openvrml::local::externproto_node_metatype::load_proto {
load_proto(externproto_node_metatype & externproto_class,
const openvrml::scene & scene,
@@ -52,12 +50,9 @@
using boost::shared_ptr;
using local::uri;
- scope_guard guard =
- make_obj_guard(
- *this->externproto_node_metatype_,
- &externproto_node_metatype::
- clear_externproto_node_types);
- boost::ignore_unused_variable_warning(guard);
+ BOOST_SCOPE_EXIT((&externproto_node_metatype_)) {
+ externproto_node_metatype_->clear_externproto_node_types();
+ } BOOST_SCOPE_EXIT_END
auto_ptr<resource_istream> in =
this->scene_->get_resource(this->alt_uris_);
Modified: trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -2,7 +2,7 @@
//
// OpenVRML
//
-// Copyright 2008 Braden McDaniel
+// Copyright 2008, 2010 Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -21,12 +21,10 @@
# include "node_metatype_registry_impl.h"
# include "conf.h"
# include <openvrml/browser.h>
-# include <boost/multi_index/detail/scope_guard.hpp>
+# include <boost/scope_exit.hpp>
# include <iostream>
# include <sstream>
-using namespace boost::multi_index::detail; // for scope_guard
-
const std::string openvrml::local::node_metatype_registry_impl::sym =
"openvrml_register_node_metatypes";
@@ -43,7 +41,10 @@
std::cerr << dl::error() << std::endl;
return 0;
}
- scope_guard handle_guard = make_guard(dl::close, handle);
+ bool succeeded = false;
+ BOOST_SCOPE_EXIT((&succeeded)(handle)) {
+ if (!succeeded) { dl::close(handle); }
+ } BOOST_SCOPE_EXIT_END
//
// Make sure the module has what we're looking for.
@@ -52,9 +53,8 @@
dl::sym(handle, openvrml::local::node_metatype_registry_impl::sym);
if (!sym) { return 0; } // handle_guard will close the module.
- const bool succeeded = registry.module_handles_.insert(handle).second;
+ succeeded = registry.module_handles_.insert(handle).second;
assert(succeeded);
- handle_guard.dismiss();
return 0;
}
Modified: trunk/src/libopenvrml/openvrml/local/uri.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/local/uri.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/libopenvrml/openvrml/local/uri.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -2,7 +2,7 @@
//
// OpenVRML
//
-// Copyright 2008 Braden McDaniel
+// Copyright 2008, 2010 Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -23,8 +23,7 @@
# include <cerrno>
# include <cstring>
# ifdef _WIN32
-# include <boost/multi_index/detail/scope_guard.hpp>
-using namespace boost::multi_index::detail; // for scope_guard
+# include <boost/scope_exit.hpp>
# endif
openvrml::local::uri::uri() OPENVRML_THROW1(std::bad_alloc):
@@ -549,7 +548,9 @@
using boost::ref;
DWORD error = GetLastError();
void * msgBuf = 0;
- scope_guard msgBuf_guard = make_guard(LocalFree, ref(msgBuf));
+ BOOST_SCOPE_EXIT((&msgBuf)) {
+ LocalFree(msgBuf);
+ } BOOST_SCOPE_EXIT_END
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS,
@@ -575,7 +576,9 @@
using boost::ref;
DWORD error = GetLastError();
void * msgBuf = 0;
- scope_guard msgBuf_guard = make_guard(LocalFree, ref(msgBuf));
+ BOOST_SCOPE_EXIT((&msgBuf)) {
+ LocalFree(msgBuf);
+ } BOOST_SCOPE_EXIT_END
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS,
Modified: trunk/src/libopenvrml/openvrml/local/xml_reader.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/local/xml_reader.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/libopenvrml/openvrml/local/xml_reader.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -2,7 +2,7 @@
//
// OpenVRML
//
-// Copyright 2008 Braden McDaniel
+// Copyright 2008, 2010 Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -21,8 +21,7 @@
# include "xml_reader.h"
# ifdef _WIN32
# include <shlwapi.h>
-# include <boost/multi_index/detail/scope_guard.hpp>
-using namespace boost::multi_index::detail; // for scope_guard
+# include <boost/scope_exit.hpp>
# endif
/**
@@ -125,31 +124,33 @@
{
# ifdef _WIN32
HRESULT hr;
+ bool succeeded = false;
hr = SHCreateStreamOnFile(filename.c_str(), STGM_READ, &this->input);
+ BOOST_SCOPE_EXIT((&succeeded)(&input)) {
+ if (!succeeded && input) { input->Release(); }
+ } BOOST_SCOPE_EXIT_END
if (FAILED(hr)) {
throw std::runtime_error("failed to open file \"" + filename
+ '\"');
}
- scope_guard input_guard =
- make_obj_guard(*this->input, &IStream::Release);
hr = CreateXmlReader(__uuidof(IXmlReader),
reinterpret_cast<void **>(&this->reader),
0);
+ BOOST_SCOPE_EXIT((&succeeded)(&reader)) {
+ if (!succeeded && reader) { reader->Release(); }
+ } BOOST_SCOPE_EXIT_END
if (FAILED(hr)) {
throw std::runtime_error("failed to create XML reader");
}
- scope_guard reader_guard =
- make_obj_guard(*this->reader, &IXmlReader::Release);
hr = this->reader->SetInput(this->input);
if (FAILED(hr)) {
throw std::runtime_error("failed to set input for XML reader");
}
- input_guard.dismiss();
- reader_guard.dismiss();
+ succeeded = true;
# else
static const char * const encoding = 0;
static const int options = 0;
Modified: trunk/src/libopenvrml/openvrml/script.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/script.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/libopenvrml/openvrml/script.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -3,7 +3,8 @@
// OpenVRML
//
// Copyright 1998 Chris Morley
-// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007 Braden McDaniel
+// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+// Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -31,7 +32,7 @@
# include <boost/functional.hpp>
# include <boost/lexical_cast.hpp>
# include <boost/mpl/for_each.hpp>
-# include <boost/multi_index/detail/scope_guard.hpp>
+# include <boost/scope_exit.hpp>
# include <boost/utility.hpp>
# include <algorithm>
# include <functional>
@@ -40,9 +41,6 @@
# include <config.h>
# endif
-
-using namespace boost::multi_index::detail; // for scope_guard
-
/**
* @file openvrml/script.h
*
@@ -415,7 +413,10 @@
const dl::handle handle = dl::open(filename);
if (!handle) { return 0; } // Ignore things we can't open.
- scope_guard handle_guard = make_guard(dl::close, handle);
+ bool succeeded = false;
+ BOOST_SCOPE_EXIT((&succeeded)(handle)) {
+ if (!succeeded) { dl::close(handle); }
+ } BOOST_SCOPE_EXIT_END
//
// Make sure the module has what we're looking for.
@@ -423,9 +424,8 @@
const void * sym = dl::sym(handle, "openvrml_script_LTX_register_factory");
if (!sym) { return 0; } // handle_guard will close the module.
- const bool succeeded = registry.module_handles_.insert(handle).second;
+ succeeded = registry.module_handles_.insert(handle).second;
assert(succeeded);
- handle_guard.dismiss();
return 0;
}
@@ -1938,8 +1938,10 @@
// nodes.
//
this->add_ref();
- scope_guard guard = make_obj_guard(*this, &script_node::remove_ref);
- boost::ignore_unused_variable_warning(guard);
+ script_node & self = *this;
+ BOOST_SCOPE_EXIT((&self)) {
+ self.remove_ref();
+ } BOOST_SCOPE_EXIT_END
for (node_interface_set::const_iterator interface_ = interfaces.begin();
interface_ != interfaces.end();
Modified: trunk/src/local/libopenvrml-dl/openvrml/local/dl.cpp
===================================================================
--- trunk/src/local/libopenvrml-dl/openvrml/local/dl.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/local/libopenvrml-dl/openvrml/local/dl.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -2,7 +2,7 @@
//
// OpenVRML
//
-// Copyright 2008 Braden McDaniel
+// Copyright 2008, 2009, 2010 Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -21,12 +21,10 @@
# include "dl.h"
# include <boost/filesystem.hpp>
# include <boost/ref.hpp>
+# include <boost/scope_exit.hpp>
# include <boost/tokenizer.hpp>
-# include <boost/multi_index/detail/scope_guard.hpp>
# include <sstream>
-using namespace boost::multi_index::detail; // for scope_guard
-
int openvrml::local::dl::init()
{
# ifdef _WIN32
@@ -130,7 +128,9 @@
# ifdef _WIN32
const DWORD err = GetLastError();
char * buf = 0;
- scope_guard buf_guard = make_guard(LocalFree, boost::ref(buf));
+ BOOST_SCOPE_EXIT((buf)) {
+ LocalFree(buf);
+ } BOOST_SCOPE_EXIT_END
static const LPCVOID source = 0;
static const DWORD buf_size = 0;
static va_list * const args = 0;
Modified: trunk/src/mozilla-plugin/openvrml.cpp
===================================================================
--- trunk/src/mozilla-plugin/openvrml.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/mozilla-plugin/openvrml.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -2,7 +2,7 @@
//
// OpenVRML Mozilla plug-in
//
-// Copyright 2004, 2005, 2006, 2007, 2008 Braden McDaniel
+// Copyright 2004, 2005, 2006, 2007, 2008, 2010 Braden McDaniel
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
@@ -25,9 +25,8 @@
# include <vector>
# include <sys/socket.h>
# include <sys/wait.h>
-# include <boost/concept_check.hpp>
# include <boost/lexical_cast.hpp>
-# include <boost/multi_index/detail/scope_guard.hpp>
+# include <boost/scope_exit.hpp>
# include <boost/noncopyable.hpp>
# include <boost/ref.hpp>
# include <boost/scoped_ptr.hpp>
@@ -75,8 +74,6 @@
# include "browser-factory-client-glue.h"
# include "browser-client-glue.h"
-using namespace boost::multi_index::detail; // for scope_guard
-
namespace {
void printerr(const char * str);
@@ -169,7 +166,9 @@
G_TYPE_NONE, 0);
GError * error = 0;
- scope_guard error_guard = make_guard(g_error_free, boost::ref(error));
+ BOOST_SCOPE_EXIT((&error)) {
+ if (error) { g_error_free(error); }
+ } BOOST_SCOPE_EXIT_END
klass->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
if (!klass->connection) {
g_critical("Failed to open connection to bus: %s", error->message);
@@ -184,8 +183,9 @@
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS);
- scope_guard driver_proxy_guard = make_guard(g_object_unref, driver_proxy);
- boost::ignore_unused_variable_warning(driver_proxy_guard);
+ BOOST_SCOPE_EXIT((driver_proxy)) {
+ g_object_unref(driver_proxy);
+ } BOOST_SCOPE_EXIT_END
guint request_ret;
if (!org_freedesktop_DBus_request_name(driver_proxy,
@@ -200,7 +200,6 @@
dbus_g_object_type_install_info(
OPENVRML_NP_TYPE_BROWSER_HOST,
&dbus_glib_openvrml_np_browser_host_object_info);
- error_guard.dismiss();
}
int openvrml_np_browser_host_get_url(OpenvrmlNpBrowserHost * const host,
@@ -598,12 +597,10 @@
return pluginInstance.write(stream, len, buffer);
}
-void NPP_StreamAsFile(const NPP instance,
+void NPP_StreamAsFile(NPP,
NPStream *,
const char * /* fname */)
{
- boost::ignore_unused_variable_warning(instance);
- assert(instance);
}
void NPP_Print(const NPP instance, NPPrint * const printInfo)
@@ -1104,9 +1101,9 @@
"/org/openvrml/BrowserFactory",
"org.openvrml.BrowserFactory");
g_return_val_if_fail(browser_factory, 0);
- scope_guard browser_factory_guard =
- make_guard(g_object_unref, G_OBJECT(browser_factory));
- boost::ignore_unused_variable_warning(browser_factory_guard);
+ BOOST_SCOPE_EXIT((browser_factory)) {
+ g_object_unref(browser_factory);
+ } BOOST_SCOPE_EXIT_END
char * browser_path = 0;
if (!org_openvrml_BrowserFactory_create_control(browser_factory,
@@ -1149,7 +1146,9 @@
OPENVRML_NP_BROWSER_HOST_GET_CLASS(this->browser_host);
GError * error = 0;
- scope_guard error_guard = make_guard(g_error_free, boost::ref(error));
+ BOOST_SCOPE_EXIT((&error)) {
+ if (error) { g_error_free(error); }
+ } BOOST_SCOPE_EXIT_END
this->browser = get_browser(browser_host_class->connection,
browser_host_class->host_name,
@@ -1160,8 +1159,6 @@
g_critical("Browser creation failed: %s", error->message);
return;
}
-
- error_guard.dismiss();
}
NPError plugin_instance::new_stream(const NPMIMEType type,
@@ -1170,7 +1167,9 @@
if (!this->browser) { return NPERR_INVALID_INSTANCE_ERROR; }
GError * error = 0;
- scope_guard error_guard = make_guard(g_error_free, boost::ref(error));
+ BOOST_SCOPE_EXIT((&error)) {
+ if (error) { g_error_free(error); }
+ } BOOST_SCOPE_EXIT_END
gboolean result = org_openvrml_Browser_new_stream(this->browser,
guint64(stream),
type,
@@ -1181,7 +1180,6 @@
error->message);
return NPERR_GENERIC_ERROR;
}
- error_guard.dismiss();
return NPERR_NO_ERROR;
}
Modified: trunk/src/node/vrml97/grouping_node_base.h
===================================================================
--- trunk/src/node/vrml97/grouping_node_base.h 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/node/vrml97/grouping_node_base.h 2010-02-14 06:28:17 UTC (rev 4107)
@@ -2,7 +2,7 @@
//
// OpenVRML
//
-// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007 Braden McDaniel
+// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010 Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -23,7 +23,7 @@
# include <openvrml/node_impl_util.h>
# include <openvrml/viewer.h>
-# include <boost/multi_index/detail/scope_guard.hpp>
+# include <boost/scope_exit.hpp>
namespace openvrml_node_vrml97 {
@@ -167,12 +167,11 @@
OPENVRML_THROW1(std::bad_alloc)
{
using namespace openvrml;
- using namespace boost::multi_index::detail; // for scope_guard
Derived & group = dynamic_cast<Derived &>(this->node());
- typedef std::vector<boost::intrusive_ptr<openvrml::node> > children_t;
- children_t children = group.children_.mfnode::value();
+ typedef std::vector<boost::intrusive_ptr<node> > children_t;
+ children_t children = group.children_.value();
for (children_t::const_iterator n = value.value().begin();
n != value.value().end();
@@ -190,19 +189,21 @@
// Throws std::bad_alloc.
//
children.push_back(*n);
- scope_guard guard =
- make_obj_guard(children, &children_t::pop_back);
+ bool succeeded = false;
+ BOOST_SCOPE_EXIT_TPL((&succeeded)(&children)) {
+ if (!succeeded) { children.pop_back(); }
+ } BOOST_SCOPE_EXIT_END
child_node * const child =
node_cast<child_node *>(n->get());
if (child) {
child->relocate(); // Throws std::bad_alloc.
}
- guard.dismiss();
+ succeeded = true;
}
}
}
- group.children_.mfnode::value(children);
+ group.children_.value(children);
group.node::modified(true);
group.bounding_volume_dirty(true);
@@ -353,7 +354,6 @@
OPENVRML_THROW1(std::bad_alloc)
{
using namespace openvrml;
- using namespace boost::multi_index::detail; // for scope_guard
typedef std::vector<boost::intrusive_ptr<openvrml::node> > children_t;
children_t children;
@@ -367,12 +367,14 @@
// least.
//
children.push_back(*n); // Throws std::bad_alloc.
- scope_guard guard =
- make_obj_guard(children, &children_t::pop_back);
+ bool succeeded = false;
+ BOOST_SCOPE_EXIT_TPL((&succeeded)(&children)) {
+ if (!succeeded) { children.pop_back(); }
+ } BOOST_SCOPE_EXIT_END
child_node * const child =
node_cast<child_node *>(n->get());
if (child) { child->relocate(); } // Throws std::bad_alloc.
- guard.dismiss();
+ succeeded = true;
}
this->children_.mfnode::value(children);
Modified: trunk/src/node/vrml97/image_stream_listener.cpp
===================================================================
--- trunk/src/node/vrml97/image_stream_listener.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/node/vrml97/image_stream_listener.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -2,7 +2,7 @@
//
// OpenVRML
//
-// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007 Braden McDaniel
+// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010 Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -24,7 +24,7 @@
# include <sstream>
# include <boost/algorithm/string/predicate.hpp>
-# include <boost/multi_index/detail/scope_guard.hpp>
+# include <boost/scope_exit.hpp>
# include "image_stream_listener.h"
openvrml_node_vrml97::image_stream_listener::image_reader::~image_reader()
@@ -204,14 +204,15 @@
stream_listener(stream_listener),
gray_palette(false)
{
- using namespace boost::multi_index::detail; // for scope_guard
this->png_ptr_ =
png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
if (!this->png_ptr_) { throw std::bad_alloc(); }
- scope_guard guard = make_guard(&png_destroy_read_struct,
- &this->png_ptr_,
- &this->info_ptr_,
- png_infopp(0));
+ bool succeeded = false;
+ BOOST_SCOPE_EXIT((&succeeded)(&png_ptr_)(&info_ptr_)) {
+ if (!succeeded) {
+ png_destroy_read_struct(&png_ptr_, &info_ptr_, png_infopp(0));
+ }
+ } BOOST_SCOPE_EXIT_END
this->info_ptr_ = png_create_info_struct(this->png_ptr_);
if (!this->info_ptr_) { throw std::bad_alloc(); }
@@ -221,7 +222,7 @@
openvrml_png_info_callback,
openvrml_png_row_callback,
openvrml_png_end_callback);
- guard.dismiss();
+ succeeded = true;
}
openvrml_node_vrml97::image_stream_listener::png_reader::~png_reader()
Modified: trunk/src/node/vrml97/text.cpp
===================================================================
--- trunk/src/node/vrml97/text.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/node/vrml97/text.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -3,7 +3,8 @@
// OpenVRML
//
// Copyright 1998 Chris Morley
-// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Braden McDaniel
+// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
+// Braden McDaniel
// Copyright 2002 S. K. Bose
//
// This library is free software; you can redistribute it and/or modify it
@@ -43,7 +44,7 @@
# endif
# endif
# include <boost/array.hpp>
-# include <boost/multi_index/detail/scope_guard.hpp>
+# include <boost/scope_exit.hpp>
# ifdef HAVE_CONFIG_H
# include <config.h>
@@ -1467,8 +1468,6 @@
{
using std::vector;
# ifdef _WIN32
- using namespace boost::multi_index::detail; // for scope_guard
-
LOGFONT lf;
lf.lfHeight = 0;
lf.lfWidth = 0;
@@ -1485,7 +1484,9 @@
lf.lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN;
HDC hdc = CreateCompatibleDC(0);
- scope_guard hdc_guard = make_guard(&DeleteDC, hdc);
+ BOOST_SCOPE_EXIT((hdc)) {
+ DeleteDC(hdc);
+ } BOOST_SCOPE_EXIT_END
HFONT hfont = CreateFontIndirect(&lf);
SelectObject(hdc, hfont);
TCHAR faceName[256] = {};
@@ -1513,7 +1514,9 @@
KEY_READ,
&fontsKey);
if (result != ERROR_SUCCESS) { /* bail */ }
- scope_guard fontsKey_guard = make_guard(&RegCloseKey, fontsKey);
+ BOOST_SCOPE_EXIT((fontsKey)) {
+ RegCloseKey(fontsKey);
+ } BOOST_SCOPE_EXIT_END
DWORD maxValueNameLen, maxValueLen;
result = RegQueryInfoKey(fontsKey,
@@ -1578,7 +1581,6 @@
face_index = 0;
# else
using std::string;
- using namespace boost::multi_index::detail; // for scope_guard
string fontName;
//
@@ -1621,9 +1623,9 @@
FcNameParse(unsigned_char_string(fontName.begin(),
fontName.end()).c_str());
if (!initialPattern) { throw std::bad_alloc(); }
- scope_guard initialPattern_guard =
- make_guard(&FcPatternDestroy, initialPattern);
- boost::ignore_unused_variable_warning(initialPattern_guard);
+ BOOST_SCOPE_EXIT((initialPattern)) {
+ FcPatternDestroy(initialPattern);
+ } BOOST_SCOPE_EXIT_END
//
// Set the language.
@@ -1642,9 +1644,9 @@
FcFontMatch(0, initialPattern, &result);
if (result != FcResultMatch) { throw FontconfigError(result); }
assert(matchedPattern);
- scope_guard matchedPattern_guard =
- make_guard(&FcPatternDestroy, matchedPattern);
- boost::ignore_unused_variable_warning(matchedPattern_guard);
+ BOOST_SCOPE_EXIT((matchedPattern)) {
+ FcPatternDestroy(matchedPattern);
+ } BOOST_SCOPE_EXIT_END
FcChar8 * filename_c_str = 0;
result = FcPatternGetString(matchedPattern,
Modified: trunk/src/openvrml-player/curlbrowserhost.cpp
===================================================================
--- trunk/src/openvrml-player/curlbrowserhost.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/openvrml-player/curlbrowserhost.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -1,7 +1,7 @@
// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*-
//
// OpenVRML Player
-// Copyright 2008 Braden McDaniel
+// Copyright 2008, 2010 Braden McDaniel
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
@@ -25,15 +25,12 @@
# include <browser-client-glue.h>
# include <dbus/dbus-glib-bindings.h>
# include <dbus/dbus-protocol.h>
-# include <boost/concept_check.hpp>
-# include <boost/multi_index/detail/scope_guard.hpp>
+# include <boost/scope_exit.hpp>
# include <boost/ref.hpp>
# include <list>
# include <vector>
# include <string.h>
-using namespace boost::multi_index::detail; // for scope_guard
-
# define OPENVRML_PLAYER_CURL_BROWSER_HOST_ERROR \
openvrml_player_curl_browser_host_error_quark()
@@ -153,7 +150,9 @@
G_TYPE_NONE, 0);
GError * error = 0;
- scope_guard error_guard = make_guard(g_error_free, boost::ref(error));
+ BOOST_SCOPE_EXIT((&error)) {
+ if (error) { g_error_free(error); }
+ } BOOST_SCOPE_EXIT_END
klass->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
if (!klass->connection) {
g_critical("Failed to open connection to bus: %s", error->message);
@@ -168,8 +167,9 @@
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS);
- scope_guard driver_proxy_guard = make_guard(g_object_unref, driver_proxy);
- boost::ignore_unused_variable_warning(driver_proxy_guard);
+ BOOST_SCOPE_EXIT((driver_proxy)) {
+ g_object_unref(G_OBJECT(driver_proxy));
+ } BOOST_SCOPE_EXIT_END
guint request_ret;
if (!org_freedesktop_DBus_request_name(driver_proxy,
@@ -196,7 +196,6 @@
dbus_g_object_type_install_info(
OPENVRML_PLAYER_TYPE_CURL_BROWSER_HOST,
&dbus_glib_openvrml_player_curl_browser_host_object_info);
- error_guard.dismiss();
}
void openvrml_player_curl_browser_host_get_property(GObject * const obj,
@@ -258,7 +257,9 @@
OPENVRML_PLAYER_CURL_BROWSER_HOST_CLASS(klass);
GError * error = 0;
- scope_guard error_guard = make_guard(g_error_free, boost::ref(error));
+ BOOST_SCOPE_EXIT((&error)) {
+ if (error) { g_error_free(error); }
+ } BOOST_SCOPE_EXIT_END
g_assert(browser_host->priv->path);
browser_host->priv->browser = get_browser(browser_host_class->connection,
@@ -283,14 +284,24 @@
browser_host->priv->multi_handle = curl_multi_init();
g_return_if_fail(browser_host->priv->multi_handle);
- scope_guard multi_handle_guard =
- make_guard(curl_multi_cleanup, browser_host->priv->multi_handle);
+ bool succeeded = false;
+ BOOST_SCOPE_EXIT((&succeeded)(&browser_host)) {
+ if (!succeeded) {
+ curl_multi_cleanup(browser_host->priv->multi_handle);
+ }
+ } BOOST_SCOPE_EXIT_END
try {
+ bool succeeded = false;
+
browser_host->priv->curl_source =
curl_source_new(browser_host->priv->multi_handle);
- scope_guard curl_source_guard =
- make_guard(g_source_unref, browser_host->priv->curl_source);
+ BOOST_SCOPE_EXIT((&succeeded)(&browser_host)) {
+ if (!succeeded && browser_host->priv->curl_source) {
+ g_source_unref(browser_host->priv->curl_source);
+ browser_host->priv->curl_source = 0;
+ }
+ } BOOST_SCOPE_EXIT_END
g_source_set_callback(
browser_host->priv->curl_source,
@@ -298,8 +309,9 @@
browser_host,
0);
guint source_id = g_source_attach(browser_host->priv->curl_source, 0);
- scope_guard source_attach_guard =
- make_guard(g_source_remove, source_id);
+ BOOST_SCOPE_EXIT((&succeeded)(source_id)) {
+ if (!succeeded && source_id != 0) { g_source_remove(source_id); }
+ } BOOST_SCOPE_EXIT_END
browser_host->priv->stream_data =
g_hash_table_new_full(
@@ -309,14 +321,12 @@
openvrml_player_curl_browser_host_delete_curl_stream_data);
g_return_if_fail(browser_host->priv->stream_data);
- source_attach_guard.dismiss();
- curl_source_guard.dismiss();
+ succeeded = true;
} catch (std::bad_alloc & ex) {
g_critical("%s", ex.what());
}
- multi_handle_guard.dismiss();
- error_guard.dismiss();
+ succeeded = true;
}
void openvrml_player_curl_browser_host_unrealize(GtkWidget * const widget)
@@ -459,14 +469,20 @@
{
CURL * const handle = curl_easy_init();
try {
- curl_stream_data * const stream_data =
- new curl_stream_data(handle, url, host->priv->browser);
- scope_guard stream_data_guard =
- make_guard(
- openvrml_player_curl_browser_host_delete_curl_stream_data,
- stream_data);
- g_hash_table_insert(host->priv->stream_data, handle, stream_data);
- stream_data_guard.dismiss();
+ curl_stream_data * stream_data = 0;
+ {
+ bool succeeded = false;
+ stream_data =
+ new curl_stream_data(handle, url, host->priv->browser);
+ BOOST_SCOPE_EXIT((&succeeded)(stream_data)) {
+ if (!succeeded) {
+ openvrml_player_curl_browser_host_delete_curl_stream_data(
+ stream_data);
+ }
+ } BOOST_SCOPE_EXIT_END
+ g_hash_table_insert(host->priv->stream_data, handle, stream_data);
+ succeeded = true;
+ }
CURLcode setopt_result;
setopt_result = curl_easy_setopt(handle,
@@ -860,35 +876,38 @@
CURL_BROWSER_HOST_CURL_EASY_RETURN_VAL_IF_ERROR(getinfo_result, 0);
GError * error = 0;
+ BOOST_SCOPE_EXIT((&error)) {
+ if (error) { g_error_free(error); }
+ } BOOST_SCOPE_EXIT_END
+
GFile * file = 0;
- scope_guard file_guard = make_guard(g_object_unref, ref(file));
GFileInfo * info = 0;
- scope_guard info_guard = make_guard(g_object_unref, ref(info));
- if (!type) {
- file = g_file_new_for_uri(stream_data.url());
- static GCancellable * const cancellable = 0;
- info = g_file_query_info(file,
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
- G_FILE_QUERY_INFO_NONE,
- cancellable,
- &error);
- if (error) {
- g_warning(error->message);
- g_error_free(error);
- error = 0;
+ BOOST_SCOPE_EXIT((&type)(&file)(&info)) {
+ if (type) {
+ if (file) { g_object_unref(file); }
+ if (info) { g_object_unref(info); }
}
- if (info) {
- type =
- g_file_info_get_attribute_string(
- info,
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
- }
- } else {
- info_guard.dismiss();
- file_guard.dismiss();
+ } BOOST_SCOPE_EXIT_END
+
+ file = g_file_new_for_uri(stream_data.url());
+ static GCancellable * const cancellable = 0;
+ info = g_file_query_info(file,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ G_FILE_QUERY_INFO_NONE,
+ cancellable,
+ &error);
+ if (error) {
+ g_warning(error->message);
+ g_error_free(error);
+ error = 0;
}
+ if (info) {
+ type =
+ g_file_info_get_attribute_string(
+ info,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
+ }
- scope_guard error_guard = make_guard(g_error_free, boost::ref(error));
gboolean new_stream_result =
org_openvrml_Browser_new_stream(
stream_data.browser(),
@@ -903,8 +922,6 @@
}
stream_data.initialize();
-
- error_guard.dismiss();
}
//
@@ -950,9 +967,9 @@
"/org/openvrml/BrowserFactory",
"org.openvrml.BrowserFactory");
g_return_val_if_fail(browser_factory, 0);
- scope_guard browser_factory_guard =
- make_guard(g_object_unref, G_OBJECT(browser_factory));
- boost::ignore_unused_variable_warning(browser_factory_guard);
+ BOOST_SCOPE_EXIT((browser_factory)) {
+ g_object_unref(G_OBJECT(browser_factory));
+ } BOOST_SCOPE_EXIT_END
char * browser_path = 0;
if (!org_openvrml_BrowserFactory_create_control(
Modified: trunk/src/openvrml-player/filechooserdialog.cpp
===================================================================
--- trunk/src/openvrml-player/filechooserdialog.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/openvrml-player/filechooserdialog.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -1,6 +1,6 @@
// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*-
//
-// Copyright 2007 Braden McDaniel
+// Copyright 2007, 2010 Braden McDaniel
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
@@ -17,12 +17,8 @@
//
# include <gtk/gtk.h>
-# include <boost/concept_check.hpp>
-# include <boost/multi_index/detail/scope_guard.hpp>
# include "filechooserdialog.h"
-using namespace boost::multi_index::detail; // for scope_guard
-
G_DEFINE_TYPE(OpenvrmlPlayerFileChooserDialog,
openvrml_player_file_chooser_dialog,
GTK_TYPE_FILE_CHOOSER_DIALOG)
@@ -67,26 +63,19 @@
GtkFileFilter * const world_filter = gtk_file_filter_new();
g_return_val_if_fail(world_filter, 0);
- scope_guard world_filter_guard = make_guard(g_object_unref,
- world_filter);
- boost::ignore_unused_variable_warning(world_filter_guard);
gtk_file_filter_set_name(world_filter, "VRML/X3D worlds");
gtk_file_filter_add_mime_type(world_filter, "x-world/x-vrml");
gtk_file_filter_add_mime_type(world_filter, "model/vrml");
gtk_file_filter_add_mime_type(world_filter, "model/x3d-vrml");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(obj), world_filter);
- world_filter_guard.dismiss();
GtkFileFilter * const all_filter = gtk_file_filter_new();
g_return_val_if_fail(all_filter, 0);
- scope_guard all_filter_guard = make_guard(g_object_unref, all_filter);
- boost::ignore_unused_variable_warning(all_filter_guard);
gtk_file_filter_set_name(all_filter, "All files");
gtk_file_filter_add_pattern(all_filter, "*");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(obj), all_filter);
- all_filter_guard.dismiss();
return obj;
}
Modified: trunk/src/openvrml-player/player.cpp
===================================================================
--- trunk/src/openvrml-player/player.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/openvrml-player/player.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -1,6 +1,6 @@
// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*-
//
-// Copyright 2006, 2007, 2008 Braden McDaniel
+// Copyright 2006, 2007, 2008, 2010 Braden McDaniel
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
@@ -19,9 +19,8 @@
# include <curl/curl.h>
# include <string>
# include <vector>
-# include <boost/concept_check.hpp>
# include <boost/lexical_cast.hpp>
-# include <boost/multi_index/detail/scope_guard.hpp>
+# include <boost/scope_exit.hpp>
# include <boost/ref.hpp>
# include <dbus/dbus-glib.h>
# include <libgnomeui/libgnomeui.h>
@@ -35,8 +34,6 @@
# include <config.h>
# endif
-using namespace boost::multi_index::detail; // for scope_guard
-
extern "C" {
//
// GTK+ signal handlers; GtkBuilder needs them to have external linkage in
@@ -87,8 +84,9 @@
g_critical("libcurl initialization failed");
return EXIT_FAILURE;
}
- scope_guard curl_global_guard = make_guard(curl_global_cleanup);
- boost::ignore_unused_variable_warning(curl_global_guard);
+ BOOST_SCOPE_EXIT() {
+ curl_global_cleanup();
+ } BOOST_SCOPE_EXIT_END
gchar ** remaining_args = 0;
GOptionEntry option_entries[] = {
@@ -123,7 +121,9 @@
GNOME_PARAM_NONE);
GError * error = 0;
- scope_guard error_guard = make_guard(g_error_free, ref(error));
+ BOOST_SCOPE_EXIT((&error)) {
+ if (error) { g_error_free(error); }
+ } BOOST_SCOPE_EXIT_END
GtkBuilder * const builder = builder_new(*program, &error);
if (!builder) {
g_critical("Failed to create UI builder: %s", error->message);
@@ -167,8 +167,6 @@
gtk_widget_show_all(app_window);
gtk_main();
-
- error_guard.dismiss();
}
namespace {
@@ -251,8 +249,9 @@
gchar * uri =
gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(data->file_chooser));
g_return_if_fail(uri);
- scope_guard uri_guard = make_guard(g_free, uri);
- boost::ignore_unused_variable_warning(uri_guard);
+ BOOST_SCOPE_EXIT((uri)) {
+ g_free(uri);
+ } BOOST_SCOPE_EXIT_END
openvrml_player_curl_browser_host_load_url(data->browser_host, uri);
}
@@ -277,8 +276,9 @@
gchar * uri = 0;
uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
g_return_if_fail(uri);
- scope_guard uri_guard = make_guard(g_free, uri);
- boost::ignore_unused_variable_warning(uri_guard);
+ BOOST_SCOPE_EXIT((uri)) {
+ g_free(uri);
+ } BOOST_SCOPE_EXIT_END
gtk_entry_set_text(location_entry, uri);
}
}
Modified: trunk/src/openvrml-xembed/browser.cpp
===================================================================
--- trunk/src/openvrml-xembed/browser.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/openvrml-xembed/browser.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -2,7 +2,7 @@
//
// OpenVRML XEmbed Control
//
-// Copyright 2004, 2005, 2006, 2007, 2008 Braden N. McDaniel
+// Copyright 2004, 2005, 2006, 2007, 2008, 2010 Braden N. McDaniel
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
@@ -18,7 +18,7 @@
// with this library; if not, see <http://www.gnu.org/licenses/>.
//
-# include <boost/multi_index/detail/scope_guard.hpp>
+# include <boost/scope_exit.hpp>
// Must include before X11 headers.
# include <boost/numeric/conversion/converter.hpp>
# include <X11/keysym.h>
@@ -33,8 +33,6 @@
# include <gtk/gtkdrawingarea.h>
# include <dbus/dbus.h>
-using namespace boost::multi_index::detail; // for scope_guard
-
GQuark openvrml_xembed_error_quark()
{
return g_quark_from_static_string("openvrml-xembed-error-quark");
@@ -321,6 +319,7 @@
const gchar * const host_name,
const GdkNativeWindow socket_id)
{
+ bool succeeded = false;
OpenvrmlXembedBrowser * const browser =
OPENVRML_XEMBED_BROWSER(
g_object_new(OPENVRML_XEMBED_TYPE_BROWSER,
@@ -329,21 +328,22 @@
"expect-initial-stream", expect_initial_stream,
static_cast<void *>(0)));
if (!browser) { return 0; }
- scope_guard browser_guard = make_guard(g_object_unref, browser);
+ BOOST_SCOPE_EXIT((&succeeded)(browser)) {
+ if (!succeeded) { g_object_unref(browser); }
+ } BOOST_SCOPE_EXIT_END
GSource * const browser_ready_source =
openvrml_xembed_browser_ready_source_new(browser, socket_id);
if (!browser_ready_source) { return 0; }
- scope_guard browser_ready_source_guard =
- make_guard(g_object_unref, browser_ready_source);
+ BOOST_SCOPE_EXIT((&succeeded)(browser_ready_source)) {
+ if (!succeeded) { g_object_unref(browser_ready_source); }
+ } BOOST_SCOPE_EXIT_END
gdk_threads_enter();
g_source_attach(browser_ready_source, gtk_thread_context);
gdk_threads_leave();
- browser_ready_source_guard.dismiss();
- browser_guard.dismiss();
-
+ succeeded = true;
return browser;
}
@@ -733,8 +733,9 @@
NULL);
g_assert(browser);
- scope_guard browser_guard = make_guard(g_object_unref, browser);
- boost::ignore_unused_variable_warning(browser_guard);
+ BOOST_SCOPE_EXIT((browser)) {
+ g_object_unref(browser);
+ } BOOST_SCOPE_EXIT_END
browser_plug->priv->drawing_area =
GTK_DRAWING_AREA(g_object_new(GTK_TYPE_DRAWING_AREA, 0));
@@ -1260,12 +1261,6 @@
namespace {
- void cleanup_private_connection(DBusConnection * const connection)
- {
- dbus_connection_close(connection);
- dbus_connection_unref(connection);
- }
-
int browser_host_proxy::do_get_url(const std::string & url)
{
//
@@ -1275,7 +1270,9 @@
//
DBusError error;
dbus_error_init(&error);
- scope_guard error_guard = make_guard(dbus_error_free, &error);
+ BOOST_SCOPE_EXIT((&error)) {
+ dbus_error_free(&error);
+ } BOOST_SCOPE_EXIT_END
DBusConnection * const connection =
dbus_bus_get_private(DBUS_BUS_SESSION, &error);
if (!connection) {
@@ -1283,8 +1280,10 @@
error.message);
return -1;
}
- scope_guard connection_guard =
- make_guard(cleanup_private_connection, connection);
+ BOOST_SCOPE_EXIT((connection)) {
+ dbus_connection_close(connection);
+ dbus_connection_unref(connection);
+ } BOOST_SCOPE_EXIT_END
DBusMessage * const get_url_call =
dbus_message_new_method_call(
@@ -1292,8 +1291,9 @@
dbus_g_proxy_get_path(this->browser_.priv->control_host),
dbus_g_proxy_get_interface(this->browser_.priv->control_host),
"GetUrl");
- scope_guard get_url_call_guard =
- make_guard(dbus_message_unref, get_url_call);
+ BOOST_SCOPE_EXIT((get_url_call)) {
+ dbus_message_unref(get_url_call);
+ } BOOST_SCOPE_EXIT_END
const char * const url_c_str = url.c_str();
bool succeeded =
@@ -1314,8 +1314,9 @@
g_warning("error fetching resource: %s", error.message);
return -1;
}
- scope_guard get_url_response_guard =
- make_guard(dbus_message_unref, get_url_response);
+ BOOST_SCOPE_EXIT((get_url_response)) {
+ dbus_message_unref(get_url_response);
+ } BOOST_SCOPE_EXIT_END
gint get_url_result = -1;
succeeded =
Modified: trunk/src/openvrml-xembed/browserfactory.cpp
===================================================================
--- trunk/src/openvrml-xembed/browserfactory.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/openvrml-xembed/browserfactory.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -2,7 +2,7 @@
//
// OpenVRML XEmbed Control
//
-// Copyright 2008 Braden McDaniel
+// Copyright 2008, 2010 Braden McDaniel
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
@@ -18,15 +18,15 @@
// with this library; if not, see <http://www.gnu.org/licenses/>.
//
-# include <boost/concept_check.hpp>
# include <boost/intrusive_ptr.hpp>
-# include <boost/multi_index/detail/scope_guard.hpp>
+# include <boost/scope_exit.hpp>
# include <boost/ref.hpp>
# include <gtk/gtk.h>
# include <dbus/dbus-glib-bindings.h>
# include <dbus/dbus-glib-lowlevel.h>
# include <map>
# include <memory>
+# include <string>
# include <cstring>
# include <cstdlib>
@@ -34,8 +34,6 @@
# include "browser-factory-server-glue.h"
# include "browser.h"
-using namespace boost::multi_index::detail; // for scope_guard
-
G_DEFINE_TYPE(OpenvrmlXembedBrowserFactory,
openvrml_xembed_browser_factory,
G_TYPE_OBJECT)
@@ -119,12 +117,14 @@
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS);
- scope_guard driver_proxy_guard =
- make_guard(g_object_unref, driver_proxy);
- boost::ignore_unused_variable_warning(driver_proxy_guard);
+ BOOST_SCOPE_EXIT((driver_proxy)) {
+ g_object_unref(driver_proxy);
+ } BOOST_SCOPE_EXIT_END
GError * error = 0;
- scope_guard error_guard = make_guard(g_error_free, boost::ref(error));
+ BOOST_SCOPE_EXIT((&error)) {
+ if (error) { g_error_free(error); }
+ } BOOST_SCOPE_EXIT_END
guint request_ret;
if (!org_freedesktop_DBus_request_name(
driver_proxy,
@@ -135,7 +135,6 @@
"failed: %s", error->message);
return 0;
}
- error_guard.dismiss();
} catch (std::bad_alloc &) {
return 0;
}
@@ -292,7 +291,9 @@
DBusGMethodInvocation * const context)
{
GError * error = 0;
- scope_guard error_guard = make_guard(g_error_free, boost::ref(error));
+ BOOST_SCOPE_EXIT((&error)) {
+ if (error) { g_error_free(error); }
+ } BOOST_SCOPE_EXIT_END
DBusGProxy * host =
dbus_g_proxy_new_for_name_owner(
@@ -330,8 +331,9 @@
G_OBJECT(browser));
char * const sender = dbus_g_method_get_sender(context);
- scope_guard sender_guard = make_guard(g_free, sender);
- boost::ignore_unused_variable_warning(sender_guard);
+ BOOST_SCOPE_EXIT((sender)) {
+ g_free(sender);
+ } BOOST_SCOPE_EXIT_END
bool succeeded;
try {
using std::make_pair;
@@ -373,8 +375,6 @@
dbus_g_method_return(context, control_obj_path);
- error_guard.dismiss();
-
return true;
}
Modified: trunk/src/openvrml-xembed/main.cpp
===================================================================
--- trunk/src/openvrml-xembed/main.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/openvrml-xembed/main.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -25,10 +25,9 @@
# include <gtk/gtk.h>
# include <dbus/dbus-glib-bindings.h>
# include <dbus/dbus-glib-lowlevel.h>
-# include <boost/concept_check.hpp>
# include <boost/function.hpp>
# include <boost/lexical_cast.hpp>
-# include <boost/multi_index/detail/scope_guard.hpp>
+# include <boost/scope_exit.hpp>
# include <boost/ref.hpp>
# include <boost/scoped_ptr.hpp>
# include <boost/thread.hpp>
@@ -40,8 +39,6 @@
# include "config.h"
# endif
-using namespace boost::multi_index::detail; // for scope_guard
-
extern "C"
G_GNUC_INTERNAL
gboolean
@@ -87,8 +84,9 @@
void operator()() const
{
GError * error = 0;
- scope_guard error_guard =
- make_guard(g_error_free, boost::ref(error));
+ BOOST_SCOPE_EXIT((&error)) {
+ if (error) { g_error_free(error); }
+ } BOOST_SCOPE_EXIT_END
DBusGConnection * const connection =
bus_get(g_main_loop_get_context(&this->dbus_thread_main_),
@@ -98,9 +96,9 @@
g_critical("Failed to get session bus: %s", error->message);
return;
}
- scope_guard connection_guard =
- make_guard(dbus_g_connection_unref, connection);
- boost::ignore_unused_variable_warning(connection_guard);
+ BOOST_SCOPE_EXIT((connection)) {
+ dbus_g_connection_unref(connection);
+ } BOOST_SCOPE_EXIT_END
OpenvrmlXembedBrowserFactory * const browser_factory =
OPENVRML_XEMBED_BROWSER_FACTORY(
@@ -109,18 +107,18 @@
"connection", connection,
"main-thread-context", &this->main_thread_context_,
static_cast<void *>(0)));
- scope_guard browser_factory_guard =
- make_guard(g_object_unref, browser_factory);
- boost::ignore_unused_variable_warning(browser_factory_guard);
+ BOOST_SCOPE_EXIT((browser_factory)) {
+ g_object_unref(browser_factory);
+ } BOOST_SCOPE_EXIT_END
DBusGProxy * driver_proxy =
dbus_g_proxy_new_for_name(connection,
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS);
- scope_guard driver_proxy_guard =
- make_guard(g_object_unref, driver_proxy);
- boost::ignore_unused_variable_warning(driver_proxy_guard);
+ BOOST_SCOPE_EXIT((driver_proxy)) {
+ g_object_unref(driver_proxy);
+ } BOOST_SCOPE_EXIT_END
dbus_g_proxy_add_signal(driver_proxy,
"NameOwnerChanged",
@@ -139,8 +137,6 @@
0);
g_main_loop_run(&this->dbus_thread_main_);
-
- error_guard.dismiss();
}
private:
@@ -179,7 +175,9 @@
};
GError * error = 0;
- scope_guard error_guard = make_guard(g_error_free, ref(error));
+ BOOST_SCOPE_EXIT((&error)) {
+ if (error) { g_error_free(error); }
+ } BOOST_SCOPE_EXIT_END
GOptionContext * const context =
g_option_context_new("- render VRML/X3D worlds");
@@ -194,7 +192,6 @@
if (version) {
cout << application_name << ' ' << PACKAGE_VERSION << endl;
- error_guard.dismiss();
return EXIT_SUCCESS;
}
@@ -206,13 +203,13 @@
using boost::thread;
GMainContext * dbus_thread_context = g_main_context_new();
- scope_guard dbus_thread_context_guard =
- make_guard(g_main_context_unref, dbus_thread_context);
- boost::ignore_unused_variable_warning(dbus_thread_context_guard);
+ BOOST_SCOPE_EXIT((dbus_thread_context)) {
+ g_main_context_unref(dbus_thread_context);
+ } BOOST_SCOPE_EXIT_END
GMainLoop * dbus_thread_main = g_main_loop_new(dbus_thread_context, false);
- scope_guard dbus_thread_main_guard =
- make_guard(g_main_loop_unref, dbus_thread_main);
- boost::ignore_unused_variable_warning(dbus_thread_main_guard);
+ BOOST_SCOPE_EXIT((dbus_thread_main)) {
+ g_main_loop_unref(dbus_thread_main);
+ } BOOST_SCOPE_EXIT_END
function<void ()> dbus_thread_func = dbus_thread_loop(*main_context,
*dbus_thread_main);
@@ -227,8 +224,6 @@
// quit in openvrml_xembed_name_owner_changed.
//
dbus_thread->join();
-
- error_guard.dismiss();
}
//
Modified: trunk/src/script/java.cpp
===================================================================
--- trunk/src/script/java.cpp 2010-02-14 04:51:31 UTC (rev 4106)
+++ trunk/src/script/java.cpp 2010-02-14 06:28:17 UTC (rev 4107)
@@ -5,7 +5,7 @@
// Copyright 1998 Chris Morley
// Copyright 2001 Henri Manson
// Copyright 2002 Thomas Flynn
-// Copyright 2007, 2008 Braden McDaniel
+// Copyright 2007, 2008, 2010 Braden McDaniel
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU...
[truncated message content] |