FLTK logo

[fltk.general] FLTK awake or Lock/unlock doesn't work

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

FLTK awake or Lock/unlock doesn't work harsh deshpande Feb 03, 2014  
 
I have solved this issue earlier, but whenever I use awake() in a new code, I have this problem.

This is the skeleton of my code and fortunately I am able to recreate the problem here :

#include "dummyClass.h"
#include <FL/Fl_Double_Window.H>
#include "pthread.h"

using namespace std;

IWindow *win1;
int f = 0;

static void update(void *p) {
    cout << "updating..." << endl;
    win1->setBtnValue(f);
    f++;
}

class AppManager : public IManager {

    IWindow *win;
public:
    void setWindow(IWindow *win) {
        this->win = win;
        win1 = win;
    }

    static void* doIt(void* p) {
        while(1) {
            cout << "doing it!" << endl;
            int i = 0;
            Fl::awake(update, (void*)i);
            sleep(2);
        }
    }

    void notify() {
        cout << "process started!" << endl;

        pthread_t t;
        pthread_create(&t, NULL, AppManager::doIt, (void*)this);
    }

    void setData(std::string data) {
        cout << data << endl;
    }
};

int main(int argc, char **argv)
{

    IManager *manager = new AppManager();
    IWindow *win = new dummyWin();

    ((dummyWin*)win)->setManager(manager);
    manager->setWindow(win);

    ((dummyWin*)win)->show();
    return Fl::run();
}

If I use, update without awake(), the changes are not observed on the widget. If I call it in awake(), the function is not called.
Where am I going wrong?

Regards
Harsh

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.