Fix gnc_owner_get_owner so that it sets the owner type.

Using the instance's QofIdType.
This commit is contained in:
John Ralls 2023-03-14 15:54:43 -07:00
parent a44b3664e2
commit 5de35f97c8
2 changed files with 18 additions and 6 deletions

View File

@ -23,6 +23,7 @@
* Boston, MA 02110-1301, USA gnu@gnu.org
*/
#include <assert.h>
#include <config.h>
#include <gtk/gtk.h>
@ -55,6 +56,10 @@
#include "gnc-prefs.h"
#include "gnc-commodity.h"
#include "gnc-report-combo.h"
#include "qofinstance.h"
#include "qoflog.h"
static const QofLogModule log_module = G_LOG_DOMAIN;
typedef enum
{
@ -277,14 +282,21 @@ void gnc_owner_get_owner (GtkWidget *widget, GncOwner *owner)
g_return_if_fail (widget != NULL);
g_return_if_fail (owner != NULL);
/* We'll assume that the owner has the proper 'type' because we
* can't change it here. Hopefully the caller has it set properly
*/
owner->owner.undefined =
QofInstance *instance =
gnc_general_search_get_selected (GNC_GENERAL_SEARCH (widget));
if (owner->type == GNC_OWNER_NONE ||
g_strcmp0(instance->e_type, qofOwnerGetType(owner)) == 0)
qofOwnerSetEntity(owner, instance);
else
{
PWARN("Owner type mismatch: Instance %s, Owner %s",
instance->e_type, qofOwnerGetType(owner));
owner->owner.undefined = instance;
}
}
void gnc_owner_set_owner (GtkWidget *widget, GncOwner *owner)
void gnc_owner_set_owner (GtkWidget *widget, const GncOwner *owner)
{
g_return_if_fail (widget != NULL);
g_return_if_fail (owner != NULL);

View File

@ -78,7 +78,7 @@ GtkWidget * gnc_owner_edit_create (GtkWidget *label, GtkWidget *hbox,
QofBook *book, GncOwner *owner);
void gnc_owner_get_owner (GtkWidget *widget, GncOwner *owner);
void gnc_owner_set_owner (GtkWidget *widget, GncOwner *owner);
void gnc_owner_set_owner (GtkWidget *widget, const GncOwner *owner);
/* An invoice select widget..