Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) WtQt CreatorUbuntu double free or corruption

 

Misc error.

 

 

 

 

 

Downloads

 

 

 

 

 

 

Full error message

 


Starting /home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption...
[2010-Dec-21 10:39:32.944903] 4083 - [notice] "Wt: initializing built-in httpd"
[2010-Dec-21 10:39:32.945024] 4083 - [notice] "Reading Wt config file: /etc/wt/wt_config.xml (location = '/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption')"
[2010-Dec-21 10:39:32.945553] 4083 - [notice] "Started server: http://0.0.0.0:8080"
[2010-Dec-21 10:39:43.642942] 4083 [/ xUoQoGdc8PLHBP5z] [notice] "Session created (#sessions = 1)"
127.0.0.1 - - [2010-Dec-21 10:39:43.644205] "POST /?wtd=NPtIdnUPPNJmyDdH&rand=13973 HTTP/1.1" 200 49
Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.19 Safari/534.13
[2010-Dec-21 10:39:43.643425] 4083 [/ xUoQoGdc8PLHBP5z] [notice] "Signal from dead session, sending reload."
[2010-Dec-21 10:39:43.643951] 4083 [/ xUoQoGdc8PLHBP5z] [notice] "Session destroyed (#sessions = 0)"
[2010-Dec-21 10:39:43.662826] 4083 [/ X2Q271JfmLuEeXmk] [notice] "Session created (#sessions = 1)"
Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.19 Safari/534.13
127.0.0.1 - - [2010-Dec-21 10:39:43.663827] "GET / HTTP/1.1" 200 1837
127.0.0.1 - - [2010-Dec-21 10:39:43.683059] "GET /?wtd=X2Q271JfmLuEeXmk&request=script&rand=306337044 HTTP/1.1" 200 28618
127.0.0.1 - - [2010-Dec-21 10:39:43.722995] "GET /resources//themes/default/wt.css HTTP/1.1" 404 85
127.0.0.1 - - [2010-Dec-21 10:39:43.723104] "GET /favicon.ico HTTP/1.1" 404 85
127.0.0.1 - - [2010-Dec-21 10:39:43.782185] "POST /?wtd=X2Q271JfmLuEeXmk&rand=44261 HTTP/1.1" 200 41
[2010-Dec-21 10:40:03.538102] 4083 [/ sc4pImXlPp5CmAkS] [notice] "Session created (#sessions = 2)"
Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.19 Safari/534.13
127.0.0.1 - - [2010-Dec-21 10:40:03.538959] "GET / HTTP/1.1" 200 1836
127.0.0.1 - - [2010-Dec-21 10:40:03.555568] "GET /?wtd=sc4pImXlPp5CmAkS&request=script&rand=758877147 HTTP/1.1" 200 28617
127.0.0.1 - - [2010-Dec-21 10:40:03.591234] "GET /resources//themes/default/wt.css HTTP/1.1" 404 85127.0.0.1 - - [2010-Dec-21 10:40:03.591252] "GET /favicon.ico HTTP/1.1" 404 85

127.0.0.1 - - [2010-Dec-21 10:40:03.659224] "POST /?wtd=sc4pImXlPp5CmAkS&rand=30593 HTTP/1.1" 200 41
[2010-Dec-21 10:40:06.481498] 4083 - [notice] "Shutdown (signal = 15)"
[2010-Dec-21 10:40:06.481585] 4083 - [notice] "Shutdown: stopping sessions."
*** glibc detected *** /home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption: double free or corruption (fasttop): 0x0854a440 ***
======= Backtrace: =========
/lib/libc.so.6(+0x6c501)[0xb6e61501]
/lib/libc.so.6(+0x6dd70)[0xb6e62d70]
/lib/libc.so.6(cfree+0x6d)[0xb6e65e5d]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xb703e441]
/usr/lib/libwt.so.21(_ZN2Wt17StdWidgetItemImplD0Ev+0x4b)[0xb751463b]
/usr/lib/libwt.so.21(_ZN2Wt11WWidgetItemD0Ev+0x34)[0xb76a8bd4]
/usr/lib/libwt.so.21(_ZN2Wt4Impl4GridD1Ev+0x74)[0xb75b69e4]
/usr/lib/libwt.so.21(_ZN2Wt11WVBoxLayoutD0Ev+0x36)[0xb7685c06]
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption[0x804cc85]
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption[0x804ce7c]
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption[0x804c17a]
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption(_ZN5boost6detail12shared_countD1Ev+0x1c)[0x804c1de]
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption[0x804ca80]
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption[0x804cdf9]
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption[0x804c301]
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption[0x804c440]
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption[0x804c17a]
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption(_ZN5boost6detail12shared_countD1Ev+0x1c)[0x804c1de]
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption[0x804c206]
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption[0x804c3e9]
/usr/lib/libwt.so.21(_ZN2Wt10WebSessionD1Ev+0x3e)[0xb76ec3fe]
/usr/lib/libwt.so.21(_ZN2Wt10WebSession4killEv+0x70)[0xb76ec870]
/usr/lib/libwt.so.21(_ZN2Wt10WebSession7HandlerD1Ev+0x136)[0xb76eca16]
/usr/lib/libwt.so.21(_ZN2Wt13WebController13forceShutdownEv+0x114)[0xb7701dc4]
/usr/lib/libwthttp.so.8(_ZN2Wt7WServer4stopEv+0x39)[0xb740afb9]
/usr/lib/libwthttp.so.8(_ZN2Wt4WRunEiPPcPFPNS_12WApplicationERKNS_12WEnvironmentEE+0x306)[0xb740c2c6]
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption[0x804b573]
/lib/libc.so.6(__libc_start_main+0xe7)[0xb6e0bce7]
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption[0x804b471]
======= Memory map: ========
08048000-0804f000 r-xp 00000000 08:01 12585654   /home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption
0804f000-08050000 r--p 00006000 08:01 12585654   /home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption
08050000-08051000 rw-p 00007000 08:01 12585654   /home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption
0852d000-08574000 rw-p 00000000 00:00 0          [heap]
b05f9000-b05fa000 ---p 00000000 00:00 0
b05fa000-b0dfa000 rw-p 00000000 00:00 0
b0dfa000-b0dfb000 ---p 00000000 00:00 0
b0dfb000-b15fb000 rw-p 00000000 00:00 0
b15fb000-b15fc000 ---p 00000000 00:00 0
b15fc000-b1dfc000 rw-p 00000000 00:00 0
b1dfc000-b1dfd000 ---p 00000000 00:00 0
b1dfd000-b25fd000 rw-p 00000000 00:00 0
b25fd000-b25fe000 ---p 00000000 00:00 0
b25fe000-b2dfe000 rw-p 00000000 00:00 0
b2dfe000-b2dff000 ---p 00000000 00:00 0
b2dff000-b35ff000 rw-p 00000000 00:00 0
b35ff000-b3600000 ---p 00000000 00:00 0
b3600000-b3e00000 rw-p 00000000 00:00 0
b3e00000-b3e8a000 rw-p 00000000 00:00 0
b3e8a000-b3f00000 ---p 00000000 00:00 0
b3f47000-b3f48000 ---p 00000000 00:00 0
b3f48000-b4748000 rw-p 00000000 00:00 0
b4748000-b4749000 ---p 00000000 00:00 0
b4749000-b4f49000 rw-p 00000000 00:00 0
b4f49000-b4f4a000 ---p 00000000 00:00 0
b4f4a000-b574e000 rw-p 00000000 00:00 0
b574e000-b5781000 r-xp 00000000 08:01 9351       /lib/libpcre.so.3.12.1
b5781000-b5782000 r--p 00032000 08:01 9351       /lib/libpcre.so.3.12.1
b5782000-b5783000 rw-p 00033000 08:01 9351       /lib/libpcre.so.3.12.1
b5783000-b58ba000 r-xp 00000000 08:01 3933189    /usr/lib/libicuuc.so.42.1
b58ba000-b58bb000 ---p 00137000 08:01 3933189    /usr/lib/libicuuc.so.42.1
b58bb000-b58c3000 r--p 00137000 08:01 3933189    /usr/lib/libicuuc.so.42.1
b58c3000-b58c5000 rw-p 0013f000 08:01 3933189    /usr/lib/libicuuc.so.42.1
b58c5000-b58c7000 rw-p 00000000 00:00 0
b58c7000-b5a78000 r-xp 00000000 08:01 3932897    /usr/lib/libicui18n.so.42.1
b5a78000-b5a79000 ---p 001b1000 08:01 3932897    /usr/lib/libicui18n.so.42.1
b5a79000-b5a7e000 r--p 001b1000 08:01 3932897    /usr/lib/libicui18n.so.42.1
b5a7e000-b5a80000 rw-p 001b6000 08:01 3932897    /usr/lib/libicui18n.so.42.1
b5a80000-b5a81000 rw-p 00000000 00:00 0
b5a81000-b69c6000 r--p 00000000 08:01 3932329    /usr/lib/libicudata.so.42.1
b69c6000-b69c7000 r--p 00f44000 08:01 3932329    /usr/lib/libicudata.so.42.1
b69c7000-b6a94000 r-xp 00000000 08:01 6311       /lib/libglib-2.0.so.0.2600.0
b6a94000-b6a95000 r--p 000cc000 08:01 6311       /lib/libglib-2.0.so.0.2600.0
b6a95000-b6a96000 rw-p 000cd000 08:01 6311       /lib/libglib-2.0.so.0.2600.0
b6a96000-b6a9d000 r-xp 00000000 08:01 6820       /lib/librt-2.12.1.so
b6a9d000-b6a9e000 r--p 00006000 08:01 6820       /lib/librt-2.12.1.so
b6a9e000-b6a9f000 rw-p 00007000 08:01 6820       /lib/librt-2.12.1.so
b6a9f000-b6aa2000 r-xp 00000000 08:01 3935976    /usr/lib/libgthread-2.0.so.0.2600.0
b6aa2000-b6aa3000 r--p 00003000 08:01 3935976    /usr/lib/libgthread-2.0.so.0.2600.0
b6aa3000-b6aa4000 rw-p 00004000 08:01 3935976    /usr/lib/libgthread-2.0.so.0.2600.0
b6aa4000-b6aa6000 r-xp 00000000 08:01 6520       /lib/libdl-2.12.1.so
b6aa6000-b6aa7000 r--p 00001000 08:01 6520       /lib/libdl-2.12.1.so
b6aa7000-b6aa8000 rw-p 00002000 08:01 6520       /lib/libdl-2.12.1.so
b6aa8000-b6aa9000 rw-p 00000000 00:00 0
b6aa9000-b6abb000 r-xp 00000000 08:01 3935387    /usr/lib/libboost_filesystem.so.1.42.0
b6abb000-b6abc000 r--p 00011000 08:01 3935387    /usr/lib/libboost_filesystem.so.1.42.0
b6abc000-b6abd000 rw-p 00012000 08:01 3935387    /usr/lib/libboost_filesystem.so.1.42.0
b6abd000-b6bf2000 r-xp 00000000 08:01 16564      /lib/libcrypto.so.0.9.8
b6bf2000-b6bfa000 r--p 00134000 08:01 16564      /lib/libcrypto.so.0.9.8
b6bfa000-b6c09000 rw-p 0013c000 08:01 16564      /lib/libcrypto.so.0.9.8
b6c09000-b6c0c000 rw-p 00000000 00:00 0
b6c0c000-b6c50000 r-xp 00000000 08:01 16565      /lib/libssl.so.0.9.8
b6c50000-b6c51000 ---p 00044000 08:01 16565      /lib/libssl.so.0.9.8
b6c51000-b6c52000 r--p 00044000 08:01 16565      /lib/libssl.so.0.9.8
b6c52000-b6c55000 rw-p 00045000 08:01 16565      /lib/libssl.so.0.9.8
b6c55000-b6c68000 r-xp 00000000 08:01 6282       /lib/libz.so.1.2.3.4
b6c68000-b6c69000 r--p 00012000 08:01 6282       /lib/libz.so.1.2.3.4
b6c69000-b6c6a000 rw-p 00013000 08:01 6282       /lib/libz.so.1.2.3.4
b6c6a000-b6c79000 r-xp 00000000 08:01 3934090    /usr/lib/libboost_date_time.so.1.42.0
b6c79000-b6c7a000 ---p 0000f000 08:01 3934090    /usr/lib/libboost_date_time.so.1.42.0
b6c7a000-b6c7b000 r--p 0000f000 08:01 3934090    /usr/lib/libboost_date_time.so.1.42.0
b6c7b000-b6c7c000 rw-p 00010000 08:01 3934090    /usr/lib/libboost_date_time.so.1.42.0
b6c7c000-b6c7d000 rw-p 00000000 00:00 0
b6c7d000-b6cce000 r-xp 00000000 08:01 3933569    /usr/lib/libboost_program_options.so.1.42.0
b6cce000-b6cd0000 r--p 00050000 08:01 3933569    /usr/lib/libboost_program_options.so.1.42.0
b6cd0000-b6cd1000 rw-p 00052000 08:01 3933569    /usr/lib/libboost_program_options.so.1.42.0
b6cd1000-b6cd4000 r-xp 00000000 08:01 3935386    /usr/lib/libboost_system.so.1.42.0
b6cd4000-b6cd5000 r--p 00002000 08:01 3935386    /usr/lib/libboost_system.so.1.42.0
b6cd5000-b6cd6000 rw-p 00003000 08:01 3935386    /usr/lib/libboost_system.so.1.42.0
b6cd6000-b6ce8000 r-xp 00000000 08:01 3941122    /usr/lib/libboost_signals.so.1.42.0
b6ce8000-b6ce9000 r--p 00011000 08:01 3941122    /usr/lib/libboost_signals.so.1.42.0
b6ce9000-b6cea000 rw-p 00012000 08:01 3941122    /usr/lib/libboost_signals.so.1.42.0
b6cea000-b6ddb000 r-xp 00000000 08:01 3941838    /usr/lib/libboost_regex.so.1.42.0
b6ddb000-b6dde000 r--p 000f0000 08:01 3941838    /usr/lib/libboost_regex.so.1.42.0
b6dde000-b6ddf000 rw-p 000f3000 08:01 3941838    /usr/lib/libboost_regex.so.1.42.0
b6ddf000-b6de0000 rw-p 00000000 00:00 0
b6de0000-b6df2000 r-xp 00000000 08:01 3934223    /usr/lib/libboost_thread.so.1.42.0
b6df2000-b6df3000 r--p 00011000 08:01 3934223    /usr/lib/libboost_thread.so.1.42.0
b6df3000-b6df4000 rw-p 00012000 08:01 3934223    /usr/lib/libboost_thread.so.1.42.0
b6df4000-b6df5000 rw-p 00000000 00:00 0
b6df5000-b6f4c000 r-xp 00000000 08:01 7707       /lib/libc-2.12.1.so
b6f4c000-b6f4e000 r--p 00157000 08:01 7707       /lib/libc-2.12.1.so
b6f4e000-b6f4f000 rw-p 00159000 08:01 7707       /lib/libc-2.12.1.so
b6f4f000-b6f52000 rw-p 00000000 00:00 0
b6f52000-b6f6c000 r-xp 00000000 08:01 6305       /lib/libgcc_s.so.1
b6f6c000-b6f6d000 r--p 00019000 08:01 6305       /lib/libgcc_s.so.1
b6f6d000-b6f6e000 rw-p 0001a000 08:01 6305       /lib/libgcc_s.so.1
b6f6e000-b6f92000 r-xp 00000000 08:01 7081       /lib/libm-2.12.1.so
b6f92000-b6f93000 r--p 00023000 08:01 7081       /lib/libm-2.12.1.so
b6f93000-b6f94000 rw-p 00024000 08:01 7081       /lib/libm-2.12.1.so
b6f94000-b7073000 r-xp 00000000 08:01 3932596    /usr/lib/libstdc++.so.6.0.14
b7073000-b7077000 r--p 000de000 08:01 3932596    /usr/lib/libstdc++.so.6.0.14
b7077000-b7078000 rw-p 000e2000 08:01 3932596    /usr/lib/libstdc++.so.6.0.14
b7078000-b707f000 rw-p 00000000 00:00 0
b707f000-b7094000 r-xp 00000000 08:01 7708       /lib/libpthread-2.12.1.so
b7094000-b7095000 ---p 00015000 08:01 7708       /lib/libpthread-2.12.1.so
b7095000-b7096000 r--p 00015000 08:01 7708       /lib/libpthread-2.12.1.so
b7096000-b7097000 rw-p 00016000 08:01 7708       /lib/libpthread-2.12.1.so
b7097000-b7099000 rw-p 00000000 00:00 0
b7099000-b735e000 r-xp 00000000 08:01 525784     /home/richel/qtsdk-2010.04/lib/libQtCore.so.4.7.0
b735e000-b7367000 rw-p 002c5000 08:01 525784     /home/richel/qtsdk-2010.04/lib/libQtCore.so.4.7.0
b7367000-b7368000 rw-p 00000000 00:00 0
b7368000-b742d000 r-xp 00000000 08:01 3933251    /usr/lib/libwthttp.so.3.1.2
b742d000-b7430000 r--p 000c4000 08:01 3933251    /usr/lib/libwthttp.so.3.1.2
b7430000-b7431000 rw-p 000c7000 08:01 3933251    /usr/lib/libwthttp.so.3.1.2
b7431000-b7432000 rw-p 00000000 00:00 0
b7432000-b77dc000 r-xp 00000000 08:01 3932236    /usr/lib/libwt.so.3.1.2
b77dc000-b77ea000 r--p 003a9000 08:01 3932236    /usr/lib/libwt.so.3.1.2
b77ea000-b77ee000 rw-p 003b7000 08:01 3932236    /usr/lib/libwt.so.3.1.2
b77ee000-b77f2000 rw-p 00000000 00:00 0
b7812000-b7815000 rw-p 00000000 00:00 0
b7815000-b7816000 r-xp 00000000 00:00 0          [vdso]
b7816000-b7832000 r-xp 00000000 08:01 6407       /lib/ld-2.12.1.so
b7832000-b7833000 r--p 0001b000 08:01 6407       /lib/ld-2.12.1.so
b7833000-b7834000 rw-p 0001c000 08:01 6407       /lib/ld-2.12.1.so
bf869000-bf88a000 rw-p 00000000 00:00 0          [stack]
The program has unexpectedly finished.
/home/richel/qtsdk-2010.04/bin/Projects/Website/CppMiscErrorDoubleFreeOrCorruption-build-desktop/CppMiscErrorDoubleFreeOrCorruption exited with code 0

 

 

 

 

 

Operating system(s) or programming environment(s)

 

IDE(s):

Project type:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: CppMiscErrorDoubleFreeOrCorruption.pro

 

#-------------------------------------------------
#
# Project created by QtCreator 2010-12-14T12:41:04
#
#-------------------------------------------------
QT       += core
QT       -= gui
LIBS += -lwt -lwthttp
QMAKE_CXXFLAGS += -DNDEBUG
TARGET = CppMiscErrorDoubleFreeOrCorruption
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app
SOURCES += main.cpp \
    menuapplication.cpp \
    menuwidget.cpp
HEADERS += \
    menuapplication.h \
    menuwidget.h

 

 

 

 

 

main.cpp

 

//---------------------------------------------------------------------------
#include <Wt/WApplication>
#include "menuapplication.h"
//---------------------------------------------------------------------------
Wt::WApplication *createApplication(
  const Wt::WEnvironment& env)
{
  return new MenuApplication(env);
}
//---------------------------------------------------------------------------
int main(int argc, char **argv)
{
  return WRun(argc, argv, &createApplication);
}
//---------------------------------------------------------------------------

 

 

 

 

 

menuapplication.cpp

 

#include "menuapplication.h"
#include "menuwidget.h"
//---------------------------------------------------------------------------
MenuApplication::MenuApplication(const Wt::WEnvironment& env)
  : Wt::WApplication(env),
    m_menu(new MenuWidget)
{
  this->setTitle(__TIME__);
  root()->addWidget(m_menu.get());
}
//---------------------------------------------------------------------------

 

 

 

 

 

menuapplication.h

 

#ifndef MENUAPPLICATION_H
#define MENUAPPLICATION_H
//---------------------------------------------------------------------------
#include <boost/shared_ptr.hpp>
#include <Wt/WApplication>
//---------------------------------------------------------------------------
struct MenuWidget;
//---------------------------------------------------------------------------
struct MenuApplication : public Wt::WApplication
{
  MenuApplication(const Wt::WEnvironment& env);
  private:
  boost::shared_ptr<MenuWidget> m_menu;
};
//---------------------------------------------------------------------------
#endif // MENUAPPLICATION_H

 

 

 

 

 

menuwidget.cpp

 

//---------------------------------------------------------------------------
#include <ctime>
#include <string>
//---------------------------------------------------------------------------
#include <Wt/WPushButton>
#include <Wt/WVBoxLayout>
#include "menuwidget.h"
//---------------------------------------------------------------------------
MenuWidget::MenuWidget()
  : m_button(new Wt::WPushButton),
    //m_layout is managed by
    // - boost::shared_ptr
    // - MenuWidget
    m_layout(new Wt::WVBoxLayout(this))
{
  m_layout->addWidget(m_button.get());
}
//---------------------------------------------------------------------------

 

 

 

 

 

menuwidget.h

 

#ifndef MENUWIDGET_H
#define MENUWIDGET_H
//---------------------------------------------------------------------------
#include <boost/shared_ptr.hpp>
#include <Wt/WContainerWidget>
//---------------------------------------------------------------------------
namespace Wt
{
  struct WPushButton;
  struct WVBoxLayout;
};
//---------------------------------------------------------------------------
struct MenuWidget : public Wt::WContainerWidget
{
  MenuWidget();

  private:
  boost::shared_ptr<Wt::WPushButton> m_button;
  boost::shared_ptr<Wt::WVBoxLayout> m_layout;
};
//---------------------------------------------------------------------------
#endif // MENUWIDGET_H

 

 

 

 

 

Wt deployment

 

The application was deployed locally from Qt Creator with the run-time arguments:

 

--docroot . --http-address 0.0.0.0 --http-port 8080

 

The webpage was viewed with Google Chrome set to http://127.0.0.1:8080.

 

 

 

 

Cause

 

m_layout is managed by both a boost::shared_ptr and MenuWidget. At the closing of the application, both delete m_layout.

 

 

 

 

 

Solution

 

m_layout must be managed by either MenuWidget or boost::shared_ptr. Both solutions are okay. Personally, I let MenuWidget take care of it, because it saves typing and the #include of the Boost header file.

 

 

 

 

 

m_layout is managed by MenuWidget

 

struct MenuWidget : public Wt::WContainerWidget
{
  MenuWidget();

  private:
  boost::shared_ptr<Wt::WPushButton> m_button;
  //m_layout is managed by MenuWidget
  Wt::WVBoxLayout * const m_layout;
};

MenuWidget::MenuWidget()
  : m_button(new Wt::WPushButton),
    //m_layout is managed by MenuWidget
    m_layout(new Wt::WVBoxLayout(this))
{
  m_layout->addWidget(m_button.get());
}

 

 

 

 

 

m_layout is managed by boost::shared_ptr

 

struct MenuWidget : public Wt::WContainerWidget
{
  MenuWidget();

  private:
  boost::shared_ptr<Wt::WPushButton> m_button;
  //m_layout is managed by boost::shared_ptr
  boost::shared_ptr<Wt::WVBoxLayout> m_layout;
};

MenuWidget::MenuWidget()
  : m_button(new Wt::WPushButton),
    //m_layout is managed by boost::shared_ptr
    m_layout(new Wt::WVBoxLayout)
{
  m_layout->addWidget(m_button.get());
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict