Re: Why this code doesn't work?



Whereas you and I are running Linux, codekiddy appears to be working under Windows:

Glib::RefPtr<Gtk::Application> app = Gtk::Application::create( argc, argv, "gtkmm.exe" );

Shouldn't matter, but....


On 12/21/2015 04:48 AM, Kjell Ahlstedt wrote:
I have tested your original test case (without layout->reference()) with two combinations of module versions. I have used valgrind to find illegal memory accesses.

Test 1: gtkmm 3.16.0, gtk+ 3.16.7, pangomm 2.36.0, pango 1.36.8, glibmm 2.44.0, glib 2.46.1 Test 2: gtkmm 3.19.3, gtk+ 3.19.5, pangomm 2.39.1, pango 1.39.0, glibmm 2.47.4, glib 2.47.4

No crash or other unexpected behavior. I've also tested by combining gtkmm 3.16.0 with pangomm 2.39.1. Behaves as it should. I've also run the test case gtkmm-documentation/examples/book/drawingarea/pango_text that you asked about in a previous post on this mailing list. I only tested with the newest versions of gtkmm etc. No crash or other sign of illegal memory access.

I don't understand what makes it behave differently when you test it.

Kjell

Den 2015-12-19 kl. 21:06, skrev codekiddy:
I also have gtkmm 3.16.0 but pango version is 2.38.1

I also figured out there must some sort of forgotten reference count, after looking at stack trace layout destructor gets called twice (not sure), once by ~RefPtr::Layout and another time by Pango::Layout::~Layout

to make the code work I have done this, but I'm not sure how safe is this. but it works ^^ and no throw is made from Layout's destructor.

int main(int argc, char* argv[])
{
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create( argc, argv, "gtkmm.exe" );

class TestClass :
public Gtk::Window
{
public:
TestClass()
{
layout = (create_pango_layout("blah"));
layout->reference();
}

Glib::RefPtr<Pango::Layout> layout;
};

TestClass* instance = new TestClass;
app->run(*instance);
delete instance;
}





_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list



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