rpms/gnome-chemistry-utils/F-11 28515.patch, NONE, 1.1 gnome-chemistry-utils.spec, 1.39, 1.40
belegdol
belegdol at fedoraproject.org
Tue Jan 12 18:48:14 UTC 2010
Author: belegdol
Update of /cvs/extras/rpms/gnome-chemistry-utils/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv20311
Modified Files:
gnome-chemistry-utils.spec
Added Files:
28515.patch
Log Message:
* Sun Jan 10 2010 Julian Sikorski <belegdol[at]gmail[dot]com> - 0.10.10-2
- Added upstream patch fixing crash on come .cdx files (RH #553093, Savannah
#28515)
28515.patch:
gcp/application.cc | 3 +-
gcu/Makefile.am | 2 +
gcu/Makefile.in | 10 +++++----
gcu/bond.cc | 27 ++++++++++++++----------
gcu/bond.h | 7 +++++-
gcu/document.cc | 53 +++++++++++++++++++++++++++++++++++++++++++++++-
gcu/document.h | 32 ++++++++++++++++++++++++++++-
gcu/loader-error.cc | 43 +++++++++++++++++++++++++++++++++++++++
gcu/loader-error.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++
9 files changed, 215 insertions(+), 19 deletions(-)
--- NEW FILE 28515.patch ---
Index: libs/gcp/application.cc
===================================================================
--- libs/gcp/application.cc (révision 1232)
+++ libs/gcp/application.cc (copie de travail)
@@ -4,7 +4,7 @@
* GChemPaint library
* application.cc
*
- * Copyright (C) 2004-2008 Jean Bréfort <jean.brefort at normalesup.org>
+ * Copyright (C) 2004-2010 Jean Bréfort <jean.brefort at normalesup.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -663,6 +663,7 @@
}
pDoc->SetFileName(filename2, mime_type);
if (Load (filename2, mime_type, pDoc)) {
+ pDoc->Loaded ();
pDoc->GetView ()->AddObject (pDoc);
pDoc->GetView ()->Update (pDoc);
pDoc->GetView ()->EnsureSize ();
Index: libs/gcu/loader-error.h
===================================================================
--- libs/gcu/loader-error.h (révision 0)
+++ libs/gcu/loader-error.h (révision 0)
@@ -0,0 +1,57 @@
+// -*- C++ -*-
+
+/*
+ * Gnome Chemistry Utils
+ * gcu/loader-error.h
+ *
+ * Copyright (C) 2002-2008 Jean Bréfort <jean.brefort at normalesup.org>
+ *
+ * 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 Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef GCU_LOADER_ERROR_H
+#define GCU_LOADER_ERROR_H
+
+#include <stdexcept>
+
+namespace gcu {
+
+/*!\class loader_error gcu/loader-error.h
+Exception class derived from std::exception used for errors encountered
+when parsing a formula.
+*/
+
+class LoaderError: public std::exception
+{
+public:
+/*! Takes a character string describing the error
+*/
+ explicit LoaderError (const std::string& __arg);
+
+ virtual ~LoaderError () throw ();
+
+/*! Returns a C-style character string describing the general cause of
+ * the current error (the same string passed to the constructor).
+*/
+ virtual const char* what () const throw ();
+
+private:
+ std::string m_msg, m_id;
+};
+
+} // namespace gcu
+
+#endif // GCU_LOADER_ERROR_H
\ No newline at end of file
Index: libs/gcu/document.cc
===================================================================
--- libs/gcu/document.cc (révision 1232)
+++ libs/gcu/document.cc (copie de travail)
@@ -4,7 +4,7 @@
* Gnome Chemistry Utils
* libs/gcu/document.cc
*
- * Copyright (C) 2004-2007 Jean Bréfort <jean.brefort at normalesup.org>
+ * Copyright (C) 2004-2010 Jean Bréfort <jean.brefort at normalesup.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -27,7 +27,9 @@
#include "application.h"
#include "residue.h"
#include "dialog.h"
+#include <glib/gi18n-lib.h>
#include <cstring>
+#include <sstream>
using namespace std;
@@ -71,6 +73,13 @@
}
g_free (Id);
g_free (key);
+ if (m_PendingTable.size () > 0) {
+ std::map <std::string, list <PendingTarget> >::iterator it, end = m_PendingTable.end ();
+ if ((it = m_PendingTable.find (id)) != end) {
+ m_PendingTable[buf] = (*it).second;
+ m_PendingTable.erase (it);
+ }
+ }
return buf;
}
@@ -84,4 +93,46 @@
return Residue::GetResidue (symbol, ambiguous);
}
+bool Document::SetTarget (char const *id, Object **target, Object *parent, Object *owner) throw (std::runtime_error)
+{
+ if (target == NULL)
+ throw std::runtime_error ("Can't set a NULL target.");
+ *target = parent->GetDescendant (id);
+ if (*target)
+ return true;
+ PendingTarget pt;
+ pt.target = target;
+ pt.parent = parent;
+ pt.owner = owner;
+ m_PendingTable[id].push_back (pt);
+ return false;
+}
+
+bool Document::Loaded () throw (LoaderError)
+{
+ unsigned count = 0;
+ std::map <std::string, list <PendingTarget> >::iterator i, end = m_PendingTable.end ();
+ for (i = m_PendingTable.begin (); i != end; i++) {
+ std::string id = (*i).first;
+ std::list <PendingTarget> &l = (*i).second;
+ std::list <PendingTarget>::iterator j = l.begin (), jend = l.end ();
+ Object *obj = (*j).parent->GetDescendant (id.c_str ());
+ if (obj == NULL) {
+ m_PendingTable.clear ();
+ std::ostringstream str;
+ // Note to translators: the two strings are concatenated with the missing id between them.
+ str << _("The input contains a reference to object \"") << id << _("\" but no object with this Id is described.");
+ throw LoaderError (str.str ());
+ } else while (j != jend) {
+ *(*j).target = obj;
+ if ((*j).owner)
+ (*j).owner->OnLoaded ();
+ count++;
+ j++;
+ }
+ }
+ m_PendingTable.clear ();
+ return count > 0;
+}
+
} // namespace gcu
Index: libs/gcu/bond.cc
===================================================================
--- libs/gcu/bond.cc (révision 1232)
+++ libs/gcu/bond.cc (copie de travail)
@@ -4,7 +4,7 @@
* Gnome Chemistry Utils
* bond.cc
*
- * Copyright (C) 2001-2008 Jean Bréfort <jean.brefort at normalesup.org>
+ * Copyright (C) 2001-2010 Jean Bréfort <jean.brefort at normalesup.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -26,6 +26,7 @@
#include "bond.h"
#include "atom.h"
#include "objprops.h"
+#include "document.h"
#include <cmath>
namespace gcu
@@ -181,12 +182,10 @@
break;
}
case GCU_PROP_BOND_BEGIN: {
- char *tmp = g_strdup_printf ("a%s", value);
- Object *pObject = GetParent ()->GetDescendant (tmp);
+ char *tmp = (*value == 'a')? g_strdup (value): g_strdup_printf ("a%s", value);
+ if (!GetDocument ()->SetTarget (tmp, reinterpret_cast <Object **> (&m_Begin), GetParent (), this))
+ return false;
g_free (tmp);
- if (!pObject || (!dynamic_cast <Atom *> (pObject)))
- return false;
- m_Begin = (Atom*) pObject;
if (m_End) {
m_Begin->AddBond (this);
m_End->AddBond (this);
@@ -194,12 +193,10 @@
break;
}
case GCU_PROP_BOND_END: {
- char *tmp = g_strdup_printf ("a%s", value);
- Object *pObject = GetParent ()->GetDescendant (tmp);
+ char *tmp = (*value == 'a')? g_strdup (value): g_strdup_printf ("a%s", value);
+ if (!GetDocument ()->SetTarget (tmp, reinterpret_cast <Object **> (&m_End), GetParent (), this))
+ return false;
g_free (tmp);
- if (!pObject || (!dynamic_cast <Atom *> (pObject)))
- return false;
- m_End = (Atom*) pObject;
if (m_Begin) {
m_Begin->AddBond (this);
m_End->AddBond (this);
@@ -301,4 +298,12 @@
return true;
}
+void Bond::OnLoaded ()
+{
+ if (m_Begin && m_End) {
+ m_Begin->AddBond (this);
+ m_End->AddBond (this);
+ }
+}
+
} // namespace gcu
Index: libs/gcu/loader-error.cc
===================================================================
--- libs/gcu/loader-error.cc (révision 0)
+++ libs/gcu/loader-error.cc (révision 0)
@@ -0,0 +1,43 @@
+// -*- C++ -*-
+
+/*
+ * Gnome Chemistry Utils
+ * gcu/loader-error.cc
+ *
+ * Copyright (C) 2002-2008 Jean Bréfort <jean.brefort at normalesup.org>
+ *
+ * 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 Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#include "config.h"
+#include "loader-error.h"
+
+namespace gcu {
+
+LoaderError::LoaderError (const std::string &arg):
+ std::exception (),
+ m_msg (arg)
+{
+}
+
+LoaderError::~LoaderError () throw()
+{
+}
+
+const char* LoaderError::what () const throw()
+{
+ return m_msg.c_str(); }
+}
Index: libs/gcu/document.h
===================================================================
--- libs/gcu/document.h (révision 1232)
+++ libs/gcu/document.h (copie de travail)
@@ -4,7 +4,7 @@
* Gnome Chemistry Utils
* chemistry/document.h
*
- * Copyright (C) 2004-2008 Jean Bréfort <jean.brefort at normalesup.org>
+ * Copyright (C) 2004-2010 Jean Bréfort <jean.brefort at normalesup.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -28,6 +28,7 @@
#include <gcu/object.h>
#include <gcu/dialog-owner.h>
+#include <gcu/loader-error.h>
#include <gcu/macros.h>
#include <string>
#include <set>
@@ -41,6 +42,14 @@
class Molecule;
class Residue;
+class PendingTarget
+{
+public:
+ Object *parent;
+ Object *owner;
+ Object **target;
+};
+
/*!\class Document gcu/document.h
This class is the base document class.
*/
@@ -133,6 +142,26 @@
*/
virtual Residue const *GetResidue (char const *symbol, bool *ambiguous = NULL);
+/*!
+ at param id the id of the target Object.
+ at param target where to store the found object.
+ at param parent the ancestor of the search object or NULL.
+ at param owner the owner of the reference to the search object.
+
+Search the descendant of \a parent, or of the whole document if \a parent is not set
+whose Id is \id. I not found, the parameters are stored for post loading processing
+using gcu::Document::Loaded(), and \a target is set to NULL.
+if \a owner is not NULL, post processing will call its OnLoaded() method.
+ at return true if the target object was found.
+*/
+ bool SetTarget (char const *id, Object **target, Object *parent, Object *owner = NULL) throw (std::runtime_error);
+
+/*!
+Processes pending references resulting from failed calls to SetTarget().
+ at return true if any reference was set.
+*/
+ virtual bool Loaded () throw (LoaderError);
+
private:
/*!
@@ -148,6 +177,7 @@
private:
std::map <std::string, std::string> m_TranslationTable;//used when Ids translations are necessary (on pasting...)
+ std::map <std::string, std::list <PendingTarget> > m_PendingTable;//used to set pointers to objects when loading does not occur in the ideal order
protected:
/*!
Index: libs/gcu/bond.h
===================================================================
--- libs/gcu/bond.h (révision 1232)
+++ libs/gcu/bond.h (copie de travail)
@@ -4,7 +4,7 @@
* Gnome Chemistry Utils
* bond.h
*
- * Copyright (C) 2002-2008 Jean Bréfort <jean.brefort at normalesup.org>
+ * Copyright (C) 2002-2010 Jean Bréfort <jean.brefort at normalesup.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -208,6 +208,11 @@
*/
bool ReplaceAtom (Atom* oldAtom, Atom* newAtom);
+/*!
+This method should be called when a bond has been fully loaded.
+*/
+ void OnLoaded ();
+
protected:
/*!
The order of the bond.
Index: libs/gcu/Makefile.am
===================================================================
--- libs/gcu/Makefile.am (révision 1232)
+++ libs/gcu/Makefile.am (copie de travail)
@@ -64,6 +64,7 @@
gtkspectrumviewer.cc \
isotope.cc \
loader.cc \
+ loader-error.cc \
matrix.cc \
matrix2d.cc \
molecule.cc \
@@ -111,6 +112,7 @@
gtkspectrumviewer.h \
isotope.h \
loader.h \
+ loader-error.h \
macros.h \
matrix.h \
matrix2d.h \
--- libs/gcu/Makefile.in.28515 2010-01-11 20:48:23.000000000 +0100
+++ libs/gcu/Makefile.in 2010-01-11 20:48:44.000000000 +0100
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11 from Makefile.am.
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -81,8 +81,8 @@
dialog-owner.lo document.lo element.lo filechooser.lo \
formula.lo gldocument.lo glview.lo gtkchem3dviewer.lo \
gtkcomboperiodic.lo gtkcrystalviewer.lo gtkperiodic.lo \
- gtkspectrumviewer.lo isotope.lo loader.lo matrix.lo \
- matrix2d.lo molecule.lo object.lo printable.lo \
+ gtkspectrumviewer.lo isotope.lo loader.lo loader-error.lo \
+ matrix.lo matrix2d.lo molecule.lo object.lo printable.lo \
print-setup-dlg.lo residue.lo spectrumdoc.lo spectrumview.lo \
sphere.lo value.lo vector.lo window.lo xml-utils.lo
libgcu_ at GCU_API_VER@_la_OBJECTS = \
@@ -212,7 +212,6 @@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
@@ -387,6 +386,7 @@
gtkspectrumviewer.cc \
isotope.cc \
loader.cc \
+ loader-error.cc \
matrix.cc \
matrix2d.cc \
molecule.cc \
@@ -434,6 +434,7 @@
gtkspectrumviewer.h \
isotope.h \
loader.h \
+ loader-error.h \
macros.h \
matrix.h \
matrix2d.h \
@@ -554,6 +555,7 @@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gtkperiodic.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gtkspectrumviewer.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/isotope.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/loader-error.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/loader.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/matrix.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/matrix2d.Plo at am__quote@
Index: gnome-chemistry-utils.spec
===================================================================
RCS file: /cvs/extras/rpms/gnome-chemistry-utils/F-11/gnome-chemistry-utils.spec,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -p -r1.39 -r1.40
--- gnome-chemistry-utils.spec 1 Jan 2010 14:22:31 -0000 1.39
+++ gnome-chemistry-utils.spec 12 Jan 2010 18:48:14 -0000 1.40
@@ -1,12 +1,13 @@
Name: gnome-chemistry-utils
Version: 0.10.10
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: A set of chemical utilities
Group: Applications/Engineering
License: GPLv2+
URL: http://www.nongnu.org/gchemutils/
Source0: http://download.savannah.nongnu.org/releases/gchemutils/0.10/%{name}-%{version}.tar.bz2
+Patch0: 28515.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: bodr
@@ -70,6 +71,7 @@ This package contains the mozilla plugin
%prep
%setup -q
+%patch0 -p0 -b .28515
%build
@@ -234,6 +236,10 @@ scrollkeeper-update -q || :
%changelog
+* Sun Jan 10 2010 Julian Sikorski <belegdol[at]gmail[dot]com> - 0.10.10-2
+- Added upstream patch fixing crash on come .cdx files (RH #553093, Savannah
+ #28515)
+
* Fri Jan 01 2010 Julian Sikorski <belegdol[at]gmail[dot]com> - 0.10.10-1
- Updated to 0.10.10
- Switched to wildcard for goffice plugin installation path
More information about the scm-commits
mailing list