mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Make hyperlinks in reports result in the appropriate window, not a crash.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev@9997 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -50,6 +50,8 @@
|
||||
#include "qofid-p.h"
|
||||
#include "qofobject-p.h"
|
||||
|
||||
#include "guid.h"
|
||||
|
||||
static short module = MOD_ENGINE;
|
||||
|
||||
/* ====================================================================== */
|
||||
@@ -333,4 +335,41 @@ gboolean qof_book_register (void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
typedef struct _BookLookup {
|
||||
GUID *guid;
|
||||
QofEntity *toRet;
|
||||
} BookLookup;
|
||||
|
||||
/// QofCollection 'foreach' function to find the QofEntity with the given GUID.
|
||||
static
|
||||
void
|
||||
_entity_by_guid( QofCollection *col, gpointer userData )
|
||||
{
|
||||
BookLookup *lookup;
|
||||
|
||||
lookup = (BookLookup*)userData;
|
||||
|
||||
// save some instructions if we've already seen the value.
|
||||
if ( lookup->toRet != NULL )
|
||||
return;
|
||||
|
||||
lookup->toRet = qof_collection_lookup_entity( col, lookup->guid );
|
||||
}
|
||||
|
||||
QofEntity*
|
||||
qof_book_get_entity_by_guid( QofBook *book, GUID *guid )
|
||||
{
|
||||
BookLookup lookup;
|
||||
|
||||
if ( ! (guid && book) )
|
||||
return NULL;
|
||||
|
||||
lookup.guid = guid;
|
||||
lookup.toRet = NULL;
|
||||
|
||||
qof_book_foreach_collection( book, _entity_by_guid, &lookup );
|
||||
|
||||
return lookup.toRet;
|
||||
}
|
||||
|
||||
/* ========================== END OF FILE =============================== */
|
||||
|
||||
@@ -134,7 +134,13 @@ gint64 qof_book_get_counter (QofBook *book, const char *counter_name);
|
||||
#define QOF_BOOK_KVP "qof-kvp"
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
||||
/**
|
||||
* @return The releveant QofEntity for the given GUID across all collections
|
||||
* in the book, or NULL if one cannot be found.
|
||||
**/
|
||||
QofEntity* qof_book_get_entity_by_guid( QofBook *book, GUID *entity );
|
||||
|
||||
/** deprecated */
|
||||
#define qof_book_get_guid(X) qof_entity_get_guid (QOF_ENTITY(X))
|
||||
|
||||
|
||||
@@ -168,6 +168,7 @@ gnc_html_register_url_cb (const char *location, const char *label,
|
||||
{
|
||||
GUID guid;
|
||||
GNCIdType id_type;
|
||||
QofEntity *qofEnt;
|
||||
|
||||
if (!string_to_guid (location + 5, &guid))
|
||||
{
|
||||
@@ -175,7 +176,10 @@ gnc_html_register_url_cb (const char *location, const char *label,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
id_type = xaccGUIDType (&guid, gnc_get_current_book ());
|
||||
//id_type = xaccGUIDType (&guid, gnc_get_current_book ());
|
||||
//id_type =
|
||||
qofEnt = qof_book_get_entity_by_guid( gnc_get_current_book(), &guid );
|
||||
id_type = qofEnt->e_type;
|
||||
if (id_type == GNC_ID_NONE || !safe_strcmp (id_type, GNC_ID_NULL))
|
||||
{
|
||||
result->error_message = g_strdup_printf (_("No such entity: %s"),
|
||||
|
||||
Reference in New Issue
Block a user