segfault in the refptr dtor.
- From: Luca Cappa <luca cappa i-medlab com>
- To: gtkmm-list gnome org
- Subject: segfault in the refptr dtor.
- Date: Fri, 09 Sep 2005 18:30:28 +0200
Hello
I have a seg fault on the dtor of the RefPtr upon the call to the
ResizableImage dtor. The member that its dtor fail for should be
ResizableImage::mPb. Any hint? I provide here below the sources here below.
Luca
#include <gtkmm.h>
class ResizableImage : public Gtk::DrawingArea
{
Glib::RefPtr<Gdk::Pixbuf> mPbOrig;
Glib::RefPtr<Gdk::Pixbuf> mPb;
public:
ResizableImage ();
virtual ~ResizableImage ();
protected:
std::string mImage;
public:
void setImageFile (std::string const& pImage)
{
mImage = pImage;
}
protected:
std::string mImageMask;
public:
void setImageMaskFile (std::string const& pImageMask)
{
mImageMask = pImageMask;
}
protected:
std::vector<Color> mAlphedColors;
public:
void addTransparentColor (int pR, int pG, int pB)
{
mAlphedColors.push_back (Color ("", pR, pG, pB, 0));
}
protected:
virtual void on_size_allocate (Gdk::Rectangle& allocation);
virtual void on_size_request (Gtk::Requisition* pRequisition);
protected:
Glib::RefPtr<Gdk::Pixmap> mPixmap;
public:
void setBackPixamp (Glib::RefPtr<Gdk::Pixmap> pPixmap);
protected:
virtual void on_realize ();
virtual bool on_expose_event (GdkEventExpose* event);
};
ResizableImage::ResizableImage () : DrawingArea ()
{
}
ResizableImage::~ResizableImage ()
{
//? FIXME THIS CRASH!
};
void ResizableImage::on_size_request (Gtk::Requisition* pRequisition)
{
Gtk::DrawingArea::on_size_request (pRequisition);
}
void ResizableImage::on_size_allocate (Gdk::Rectangle& allocation)
{
Gtk::DrawingArea::on_size_allocate (allocation);
if (!mPbOrig)
mPbOrig = Gdk::Pixbuf::create_from_file (mImage);
if (mPbOrig->get_width () != allocation.get_width () ||
mPbOrig->get_height () != allocation.get_height ())
mPb = mPbOrig->scale_simple (allocation.get_width (),
allocation.get_height (), Gdk::INTERP_NEAREST);
else
mPb = mPbOrig->copy ();
//Set the alphed colors.
for (std::vector<Color>::iterator lIt = mAlphedColors.begin (); lIt
!= mAlphedColors.end (); lIt++)
mPb = mPb->add_alpha (true, (*lIt).mRed, (*lIt).mGreen,
(*lIt).mBlue);
}
void ResizableImage::on_realize ()
{
Gtk::DrawingArea::on_realize ();
//Set the background pixmap if any.
if (mPixmap)
get_window ()->set_back_pixmap (mPixmap, true);
}
bool ResizableImage::on_expose_event (GdkEventExpose* event)
{
Gtk::DrawingArea::on_expose_event (event);
//Set the background pixmap if any.
if (mPixmap)
get_window ()->set_back_pixmap (mPixmap, false);
if (mPb)
{
int lWidth = mPb->get_width ();
int lHeight = mPb->get_height ();
mPb->render_to_drawable (get_window (),
get_style()->get_black_gc(), 0, 0, 0, 0, lWidth, lHeight,
Gdk::RGB_DITHER_NONE, 0, 0);
}//if
return true;
}
void ResizableImage::setBackPixamp (Glib::RefPtr<Gdk::Pixmap> pPixmap)
{
mPixmap = pPixmap;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]