Re: What is the minimum number of lines to update a gui window without user clicking a button




HelloWorld::HelloWorld() : m_textview() {

    add(m_textview);
    m_textview.show();
Glib::Thread::create(sigc::mem_fun(*this, &HelloWorld::cpp_app), true);
}
[...]
void HelloWorld::cpp_app() {
    string texttoprint = "";
    Glib::RefPtr<Gtk::TextBuffer> m_refTextBuffer;
    m_refTextBuffer = Gtk::TextBuffer::create();
    string runit(std::string c);

    texttoprint +=
"About to run a number of c++ functions\nand display the results\n";
    m_refTextBuffer->set_text(texttoprint);
    m_textview.set_buffer(m_refTextBuffer);

sleep(10); // This sleep function represents any c++ function performaing a task

I would like to clarify implementation details a bit more from this programming attempt. Can it be that the referenced text buffer is written in a thread-unsafe way here? How do think about to apply improved techniques and software ingredients like locks for memory consistency? (Andrew Potter and Gavin Lambert suggested also an alternative program structure. - https://mail.gnome.org/archives/gtkmm-list/2013-August/msg00135.html )

Regards,
Markus


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