RE: Glib::signal_timeout().connect_seconds



Mik wrote:

> bool MainWindow::onTimeout30s(int timerNumber)
> {
> clog << "MainWindow::onTimeout30s" << std::endl;
>
> clog << "mTimeoutConnection::empty " <<
> (mTimeoutConnection.empty()?"true":"false") << endl;
> clog << "mTimeoutConnection::connected " <<
> (mTimeoutConnection.connected()?"true":"false") << endl;
> }

Sledge Hammer wrote:

I am surprised that g++ doesn't give you a warning while compiling that
piece of code. In "MainWindow::onTimeout30s()" you have forgotten to
return a value. Put "return true;" If you want MainWindow::onTimeout30s()
to be called again or "return false" to disconnect the signal handler.

In other words: you should use -Wall when compiling with g++. You can catch a lot of silly typos early in the production cycle.

More generally spoken: write code that, if incorrect, will produce compiler warnings or errors, instead of code that, if incorrect, will fail while your customer is running the program.

Mark


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