[patch 07/15] [misc.diff] Minor random code tweaks.
c.shoemaker at cox.net
c.shoemaker at cox.net
Mon Oct 10 10:34:29 EDT 2005
* src/gnc-module/gnc-module.c:
- code factoring
* src/engine/qofbook.c | 24 +++---
* src/report/report-gnome/gnc-plugin-page-report.c | 10 +-
- line-wrap fixes, minor code simplications, comments
* src/app-utils/gnc-euro.c | 1
* src/app-utils/gnc-ui-util.h | 1
* src/gnome-utils/dialog-commodity.h | 4 -
* src/gnome-utils/gnc-currency-edit.c | 1
- remove #include "gnc-engine.h"
- comments
* src/backend/file/gnc-account-xml-v2.c | 9 --
- Code simplification.
src/app-utils/gnc-euro.c | 1
src/app-utils/gnc-ui-util.h | 1
src/backend/file/gnc-account-xml-v2.c | 9 --
src/engine/qofbook.c | 24 +++---
src/gnc-module/gnc-module.c | 87 +++++++++++------------
src/gnome-utils/dialog-commodity.h | 4 -
src/gnome-utils/gnc-currency-edit.c | 1
src/report/report-gnome/gnc-plugin-page-report.c | 10 +-
8 files changed, 65 insertions(+), 72 deletions(-)
Index: gnucash/src/app-utils/gnc-euro.c
===================================================================
--- gnucash.orig/src/app-utils/gnc-euro.c
+++ gnucash/src/app-utils/gnc-euro.c
@@ -26,7 +26,6 @@
#include <string.h>
#include "gnc-commodity.h"
-#include "gnc-engine.h"
#include "gnc-euro.h"
#include "gnc-ui-util.h"
Index: gnucash/src/app-utils/gnc-ui-util.h
===================================================================
--- gnucash.orig/src/app-utils/gnc-ui-util.h
+++ gnucash/src/app-utils/gnc-ui-util.h
@@ -38,7 +38,6 @@
#include <locale.h>
#include "Account.h"
-#include "gnc-engine.h"
#include "Group.h"
#include "qofbook.h"
#include "qofsession.h"
Index: gnucash/src/backend/file/gnc-account-xml-v2.c
===================================================================
--- gnucash.orig/src/backend/file/gnc-account-xml-v2.c
+++ gnucash/src/backend/file/gnc-account-xml-v2.c
@@ -327,14 +327,9 @@ static gboolean
account_slots_handler (xmlNodePtr node, gpointer act_pdata)
{
struct account_pdata *pdata = act_pdata;
- gboolean success;
- success = dom_tree_to_kvp_frame_given
- (node, xaccAccountGetSlots (pdata->account));
-
- g_return_val_if_fail(success, FALSE);
-
- return TRUE;
+ return dom_tree_to_kvp_frame_given
+ (node, xaccAccountGetSlots (pdata->account));
}
static gboolean
Index: gnucash/src/engine/qofbook.c
===================================================================
--- gnucash.orig/src/engine/qofbook.c
+++ gnucash/src/engine/qofbook.c
@@ -68,9 +68,10 @@ qof_book_init (QofBook *book)
{
if (!book) return;
- book->hash_of_collections = g_hash_table_new_full(g_str_hash, g_str_equal,
- gnc_string_cache_remove,
- coll_destroy);
+ book->hash_of_collections = g_hash_table_new_full(
+ g_str_hash, g_str_equal,
+ (GDestroyNotify)gnc_string_cache_remove, /* key_destroy_func */
+ coll_destroy); /* value_destroy_func */
qof_instance_init (&book->inst, QOF_ID_BOOK, book);
@@ -116,7 +117,7 @@ qof_book_destroy (QofBook *book)
book->shutting_down = TRUE;
gnc_engine_force_event (&book->inst.entity, GNC_EVENT_DESTROY);
- /* Call the list of finalizers, let them do thier thing.
+ /* Call the list of finalizers, let them do their thing.
* Do this before tearing into the rest of the book.
*/
g_hash_table_foreach (book->data_table_finalizers, book_final, book);
@@ -124,7 +125,9 @@ qof_book_destroy (QofBook *book)
qof_object_book_end (book);
g_hash_table_destroy (book->data_table_finalizers);
+ book->data_table_finalizers = NULL;
g_hash_table_destroy (book->data_tables);
+ book->data_tables = NULL;
qof_instance_release (&book->inst);
@@ -239,13 +242,12 @@ qof_book_get_collection (QofBook *book,
if (!book || !entity_type) return NULL;
col = g_hash_table_lookup (book->hash_of_collections, entity_type);
- if (col) return col;
-
- col = qof_collection_new (entity_type);
-
- g_hash_table_insert (book->hash_of_collections,
- gnc_string_cache_insert((gpointer) entity_type), col);
-
+ if (!col) {
+ col = qof_collection_new (entity_type);
+ g_hash_table_insert(
+ book->hash_of_collections,
+ gnc_string_cache_insert((gpointer) entity_type), col);
+ }
return col;
}
Index: gnucash/src/gnc-module/gnc-module.c
===================================================================
--- gnucash.orig/src/gnc-module/gnc-module.c
+++ gnucash/src/gnc-module/gnc-module.c
@@ -258,25 +258,36 @@ gnc_module_system_modinfo(void)
GNCModuleInfo *
gnc_module_get_info(const char * fullpath)
{
- lt_dlhandle handle;
+ lt_dlhandle handle;
+ lt_ptr modsysver;
//printf("(init) dlopening %s\n", fullpath);
handle = lt_dlopen(fullpath);
- if(handle)
- {
- lt_ptr modsysver = lt_dlsym(handle, "gnc_module_system_interface");
+ if (handle == NULL) {
+ g_warning ("Failed to dlopen() '%s': %s\n", fullpath, lt_dlerror());
+ return NULL;
+ }
+
+
+ modsysver = lt_dlsym(handle, "gnc_module_system_interface");
- /* the modsysver tells us what the expected symbols and their
- * types are */
- if (!modsysver)
- {
+ /* the modsysver tells us what the expected symbols and their
+ * types are */
+ if (!modsysver) {
//printf("(init) closing %s\n", fullpath);
//lt_dlclose(handle);
return NULL;
- }
+ }
- if(*(int *)modsysver == 0)
- {
+ if (*(int *)modsysver != 0) {
+ /* unsupported module system interface version */
+ /* printf("\n** WARNING ** : module '%s' requires newer module system\n",
+ fullpath); */
+ //lt_dlclose(handle);
+ return NULL;
+ }
+
+ {
lt_ptr initfunc = lt_dlsym(handle, "gnc_module_init");
lt_ptr pathfunc = lt_dlsym(handle, "gnc_module_path");
lt_ptr descripfunc = lt_dlsym(handle, "gnc_module_description");
@@ -284,43 +295,29 @@ gnc_module_get_info(const char * fullpat
lt_ptr revision = lt_dlsym(handle, "gnc_module_revision");
lt_ptr age = lt_dlsym(handle, "gnc_module_age");
- if(initfunc && pathfunc && descripfunc && interface &&
- revision && age)
- {
- /* we have found a gnc_module. */
- GNCModuleInfo * info = g_new0(GNCModuleInfo, 1);
- char * (* f_path)(void) = pathfunc;
- char * (* f_descrip)(void) = descripfunc;
- info->module_path = f_path();
- info->module_description = f_descrip();
- info->module_filepath = g_strdup(fullpath);
- info->module_interface = *(int *)interface;
- info->module_age = *(int *)age;
- info->module_revision = *(int *)revision;
- //printf("(init) closing %s\n", fullpath);
- //lt_dlclose(handle);
- return info;
+ if (!(initfunc && pathfunc && descripfunc && interface &&
+ revision && age)) {
+ g_warning ("module '%s' does not match module signature\n",
+ fullpath);
+ //lt_dlclose(handle);
+ return NULL;
}
- else
+
{
- g_warning ("module '%s' does not match module signature\n", fullpath);
- //lt_dlclose(handle);
- return NULL;
+ /* we have found a gnc_module. */
+ GNCModuleInfo * info = g_new0(GNCModuleInfo, 1);
+ char * (* f_path)(void) = pathfunc;
+ char * (* f_descrip)(void) = descripfunc;
+ info->module_path = f_path();
+ info->module_description = f_descrip();
+ info->module_filepath = g_strdup(fullpath);
+ info->module_interface = *(int *)interface;
+ info->module_age = *(int *)age;
+ info->module_revision = *(int *)revision;
+ //printf("(init) closing %s\n", fullpath);
+ //lt_dlclose(handle);
+ return info;
}
- }
- else
- {
- /* unsupported module system interface version */
- /* printf("\n** WARNING ** : module '%s' requires newer module system\n",
- fullpath); */
- //lt_dlclose(handle);
- return NULL;
- }
- }
- else
- {
- g_warning ("Failed to dlopen() '%s': %s\n", fullpath, lt_dlerror());
- return NULL;
}
}
Index: gnucash/src/gnome-utils/dialog-commodity.h
===================================================================
--- gnucash.orig/src/gnome-utils/dialog-commodity.h
+++ gnucash/src/gnome-utils/dialog-commodity.h
@@ -36,7 +36,6 @@
#include <gnome.h>
#include "gnc-commodity.h"
-#include "gnc-engine.h"
/** The dialog commodity types are used to determine what commodity
* namespaces the currency dialog will present to a user. These
@@ -187,8 +186,7 @@ gnc_ui_new_commodity_modal_full(const ch
*/
gnc_commodity *
gnc_ui_new_commodity_modal(const char * default_namespace,
- GtkWidget * parent
- );
+ GtkWidget * parent);
/** Allow the user to edit the information about a commodity. For
* currencies, only the price quote information may be changed. For
Index: gnucash/src/gnome-utils/gnc-currency-edit.c
===================================================================
--- gnucash.orig/src/gnome-utils/gnc-currency-edit.c
+++ gnucash/src/gnome-utils/gnc-currency-edit.c
@@ -62,7 +62,6 @@
#include "gnc-currency-edit.h"
#include "gnc-commodity.h"
-#include "gnc-engine.h"
#include "gnc-ui-util.h"
#include "messages.h"
Index: gnucash/src/report/report-gnome/gnc-plugin-page-report.c
===================================================================
--- gnucash.orig/src/report/report-gnome/gnc-plugin-page-report.c
+++ gnucash/src/report/report-gnome/gnc-plugin-page-report.c
@@ -121,7 +121,9 @@ struct GncPluginPageReportPrivate
SCM initial_report;
GNCOptionDB * initial_odb;
SCM name_change_cb_id;
-
+
+ /* keep a list of edited reports so that we can destroy them when
+ * the window is closed. */
SCM edited_reports;
/* This is set to mark the fact that we need to reload the html */
@@ -779,7 +781,8 @@ gnc_plugin_page_report_new( int reportId
}
void
-gnc_plugin_page_report_remove_edited_report(GncPluginPageReportPrivate * win, SCM report)
+gnc_plugin_page_report_remove_edited_report(GncPluginPageReportPrivate * win,
+ SCM report)
{
SCM new_edited = scm_delete(win->edited_reports, report);
scm_gc_unprotect_object(win->edited_reports);
@@ -788,7 +791,8 @@ gnc_plugin_page_report_remove_edited_rep
}
void
-gnc_plugin_page_report_add_edited_report(GncPluginPageReportPrivate * win, SCM report)
+gnc_plugin_page_report_add_edited_report(GncPluginPageReportPrivate * win,
+ SCM report)
{
SCM new_edited = scm_cons(report, win->edited_reports);
scm_gc_unprotect_object(win->edited_reports);
--
More information about the gnucash-devel
mailing list