Re: [gtk-osx-devel] Gdk::Pixbuf::create(Gdk::Window, int, int, int, int) on Mac LION



John:

Many thanks for all of your help.  The previous stack trace that I gave you was from a larger program.  Here is more of a minimal program to illustrate the error.  I cannot really get a stacktrace now as the program does not crash.

I am still struggling with being able to get gdb to step into the libraries so that I can see exactly where in the library the error is occurring.  Note that the pixbuf_ that is returned is not NULL but any use of it in further code will cause a segfault. Given the error messages coming from the pixbuf create step... this is not surprising.

How exactly do I compile gtkmm, gdk-pixbuf and glibmm with debugging support?  Seems like it should be simple but no matter where I put the -ggdb flag, the Makefile seems to ignore it.

jim...

#include <gtkmm/main.h>
#include <gtkmm/box.h>
#include <gtkmm/window.h>
#include <gtkmm/separator.h>
#include <gtkmm/textview.h>
#include <gtkmm.h>
#include <gtkmm/drawingarea.h>
#include <gtkmm/image.h>
#include <gtkmm/stock.h>
#include <iostream>
#include <cairomm/context.h>
#include <gtkmm/button.h>

class Area : public Gtk::DrawingArea
{
public:
    Area();
    virtual ~Area();
     Glib::RefPtr<Gdk::Window> myarea_win_;
protected:
    virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
    virtual void on_realize();
};

Area::Area(){}

Area::~Area(){}

bool Area::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
    return true;
}

void Area::on_realize()
{
  // We need to call the base on_realize()
  Gtk::DrawingArea::on_realize();
   myarea_win_ = get_window();
}

class PlotTest : public Gtk::Window
{
public:
  PlotTest();
  virtual ~PlotTest();
protected:
    Area myarea;

  //Signal handlers:
    void on_close_clicked();
    void on_test_clicked();

  //Child widgets:
      Gtk::TextView t_view;
      Gtk::Box m_Box_Top;
      Gtk::Button m_Button_Close;
      Gtk::Button m_Button_Test;
};

PlotTest::PlotTest() :
  m_Box_Top(Gtk::ORIENTATION_VERTICAL),
  m_Button_Close("Close"),
  m_Button_Test("Test Pixbuf Code")
{
  // Set title and border of the window
  set_title("Cairo Test");
  set_border_width(0);

  add(m_Box_Top);
  myarea.set_size_request(500, 300);
  m_Box_Top.pack_start(myarea);

  m_Box_Top.pack_start(m_Button_Close);
  m_Box_Top.pack_start(m_Button_Test);

  m_Button_Close.set_can_default();
  m_Button_Close.grab_default();

  // Connect the clicked signal of the button to
  m_Button_Close.signal_clicked().connect(sigc::mem_fun(*this,
              &PlotTest::on_close_clicked) );

  m_Button_Test.signal_clicked().connect(sigc::mem_fun(*this,
              &PlotTest::on_test_clicked) );

    show_all();
}

PlotTest::~PlotTest()
{
}

void PlotTest::on_close_clicked()
{
  hide(); //to close the application.
}

void PlotTest::on_test_clicked()
{
     int winx, winy, winw, winh;

     printf("Realized %i\n", myarea.get_realized());

     myarea.get_window()->get_geometry(winx, winy, winw, winh);

    Glib::RefPtr<Gdk::Pixbuf> pixbuf_ = Gdk::Pixbuf::create(myarea.myarea_win_, 0,0,winw,winh);

}

int main(int argc, char *argv[])
{
  Gtk::Main kit(argc, argv);

  PlotTest Prog;

  Gtk::Main::run(Prog);

  return 0;
}


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