Hi all,
compiling and running the following code, I obtain:
$ g++ test.cpp -lwt -lwthttp
$ ./a.out --docroot /usr/local/share/Wt --http-address 0.0.0.0 --http-port 11107
Reading: /etc/wt/wt_config.xml
[2011-Jan-11 13:22:08.995166] 14426 - [notice] "Wt: initializing built-in httpd"
[2011-Jan-11 13:22:08.995289] 14426 - [notice] "Reading Wt config
file: /etc/wt/wt_config.xml (location = './a.out')"
[2011-Jan-11 13:22:08.995994] 14426 - [notice] "Started server:
http://0.0.0.0:11107"
[2011-Jan-11 13:22:14.661862] 14426 [/ 3xlyZZQBXhH8kvtl] [notice]
"Session created (#sessions = 1)"
Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.7 (KHTML,
like Gecko) Chrome/7.0.517.8 Safari/534.7
192.168.21.17 - - [2011-Jan-11 13:22:14.663076] "GET / HTTP/1.1" 200 1898
MyWidget::MyWidget()
W1 parent: 0x7f70880057b0
MyWidget::MyWidget()
W1 parent: 0
192.168.21.17 - - [2011-Jan-11 13:22:14.770080] "GET
/?wtd=3xlyZZQBXhH8kvtl&request=script&rand=1116826066 HTTP/1.1" 200
30834
192.168.21.17 - - [2011-Jan-11 13:22:14.917199] "GET
/resources//themes/default/wt.css HTTP/1.1" 304 0
192.168.21.17 - - [2011-Jan-11 13:22:14.926819] "GET /favicon.ico
HTTP/1.1" 404 85
192.168.21.17 - - [2011-Jan-11 13:22:14.990106] "POST
/?wtd=3xlyZZQBXhH8kvtl&rand=10196 HTTP/1.1" 200 41
192.168.21.17 - - [2011-Jan-11 13:22:23.037061] "POST
/?wtd=3xlyZZQBXhH8kvtl&rand=95314 HTTP/1.1" 200 49
virtual MyWidget::~MyWidget()
[2011-Jan-11 13:22:23.037293] 14426 [/ 3xlyZZQBXhH8kvtl] [notice]
"Session destroyed (#sessions = 0)"
^C[2011-Jan-11 13:22:25.672518] 14426 - [notice] "Shutdown (signal = 2)"
[2011-Jan-11 13:22:25.672564] 14426 - [notice] "Shutdown: stopping sessions."
as you can see 2 MyWidget instances are created but only one is
destroyed, also after the second addWidget on same location
of previous one the first widget has no parent.
Regards
Gaetano Mendola
==========================================================================================
#include <iostream>
#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WGridLayout>
class MyWidget : public Wt::WContainerWidget {
public:
MyWidget()
: Wt::WContainerWidget()
{
std::cout << __PRETTY_FUNCTION__ << std::endl;
}
virtual ~MyWidget()
{
std::cout << __PRETTY_FUNCTION__ << std::endl;
}
};
class Application : public Wt::WApplication {
public:
Application(const Wt::WEnvironment& env)
: Wt::WApplication(env)
{
Wt::WContainerWidget* myContainer = new Wt::WContainerWidget(wApp->root());
Wt::WGridLayout* myGrid = new Wt::WGridLayout();
myContainer->setLayout(myGrid);
MyWidget* myWidget1 = new MyWidget();
myGrid->addWidget(myWidget1, 0, 0);
std::cout << "W1 parent: " << myWidget1->parent() << std::endl;
myGrid->addWidget(new MyWidget(), 0, 0);
std::cout << "W1 parent: " << myWidget1->parent() << std::endl;
}
~Application() { }
};
Wt::WApplication *createApplication(const Wt::WEnvironment& env) {
Wt::WApplication* myApplication = new Application(env);
return myApplication;
}
int main(int argc, char **argv) {
Wt::WRun(argc, argv, &createApplication);
return 1;
}
--
cpp-today.blogspot.com
------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web. Learn how to
best implement a security strategy that keeps consumers' information secure
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest