Problem wrapping GdkPixbuf* to Glib::RefPtr<Gdk::Pixbuf>



Hi Guys,

I am working with the windows gtkmm release 2.22
(gtkmm-win32-devel-2.22.0-2) and encounter a problem.
(Source code attached at the end of the post.)
I have a .dll which exports a class with a method returning a
Gdk::Pixbuf created from a GdkPixdata structure.
So the main application links to the dll, calls the function, creates
a Gtk::Image with the Gdk::Pixbuf returned and shows it in the main
window.
All this works fine if I use the debug version of the dll and the exe
or the release versions of both.

Now I want to deploy the release version of the dll. The problem is
that on execution of the debug exe with the release version of the dll
the program crashes with the following messages:

** (ImageViewer.exe:6076): CRITICAL **: file
..\..\glib\glibmm\wrap.cc: line 97: assertion `wrap_func_table != 0'
failed
** (ImageViewer.exe:6076): WARNING **: Failed to wrap object of type
'GdkPixbuf'. Hint: this error is commonly caused by failing to call a
library init() function.

I already tried calling some init functions directly after the line
Gtk::Main kit(narg, args);, but nothing helps.

I am working with MSVC2010, using the default project settings
suggested by visual studio - I just added the necessary includes,
libs, ...
In the function getPicture the pointer GdkPixbuf* pixbuf is not null
in the bespoken situation - the program fails in the following line
while trying to wrap to an object.

I'd appreciate any suggestion about how to deal with this issue!
Best regards,
Robert


Here some source code:

===========================================================
Header of the exported class:
===========================================================
#ifndef IMAGEDELIVERYDLL_H
#define IMAGEDELIVERYDLL_H

#include <gtkmm.h>
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixdata.h>

#ifdef IMAGEDELIVERYDLL_EXPORTS
#define IMAGEDELIVERYDLL_EXPORTS __declspec(dllexport)
#else
#define IMAGEDELIVERYDLL_EXPORTS __declspec(dllimport)
#endif

class IMAGEDELIVERYDLL_EXPORTS ImageDelivery
{
public:
	static Glib::RefPtr<Gdk::Pixbuf> getPicture();
};

#endif

===========================================================
Implementation of the exported class' function:
===========================================================
#include "imageDeliveryDll.h"
#include "pic_background1.h"

Glib::RefPtr<Gdk::Pixbuf> ImageDelivery::getPicture()
{
	GdkPixbuf* pixbuf = gdk_pixbuf_from_pixdata(&background_xpm1, false,
NULL); // background_xpm1 is a structure generated by
gdk-pixbuf-csource.exe
	return Glib::wrap(pixbuf, true);
}

===========================================================
Implementation of the application which includes the dll.
===========================================================
#include <gtkmm.h>
#include <gtk/gtk.h>
#include "imageDeliveryDll.h"

int main(int narg, char *args[])
{
	Gtk::Main kit(narg, args);
	Gtk::Window win;
	Glib::RefPtr<Gdk::Pixbuf> pb = ImageDelivery::getPicture();

	Gtk::Image img(pb);
	win.add(img);
	win.show_all();

	if(&win){
		kit.run(win);
	}

	return 0;
}
===========================================================


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]