uso codeblock 8.02
compilando con gcc 3.4.5 sotto Vista
Gui mdi application
se compongo una stringa con append, nei seguenti casi:
a) appendo un stringa esterna (extern char *txt) questa è stata trasformata con .c_str() (era una string formata con append)
b) formo la stringa prendendo i valori inseriti in un contenitore list<string>xxx
pensado fosse un problema di allocazione dinamica ho provato a definire un array globale statico, ma è lo stesso
c) formo la stringa prendendo in valori inseriti in un char **subTitle=new char[4];
non sempre si presenta questo errore, a volte blocca solamente l'applicazione;codice:string tmpStr, tywin; tywin="win test"; tmpStr.append(tywin); tmpStr.append(" prova"); //questo si riferisce al tentativo c). if(*getSubTitle==1) { for(int i=0; i<*nrsubT; i++) { tmpStr.append(subTitle[i]); } } SetWindowText(hwnd,tmpStr.c_str());
da debug ho questo:
Management.exe caused an Access Violation at location 77d81ad5 in module ntdll.dll Reading from location 003f0024.
Registers:
eax=00b86e98 ebx=00b80000 ecx=003f0020 edx=00290020 esi=00b86e90 edi=00b86e60
eip=77d81ad5 esp=0022eda0 ebp=0022edc8 iopl=0 nv up ei pl zr na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010246
Call stack:
77D81AD5 ntdll.dll:77D81AD5 RtlTryEnterCriticalSection
77D81D37 ntdll.dll:77D81D37 RtlTryEnterCriticalSection
77D81C21 ntdll.dll:77D81C21 RtlTryEnterCriticalSection
773A7A7E kernel32.dll:773A7A7E HeapFree
7744A097 msvcrt.dll:7744A097 free
0042A655 Management.exe:0042A655
004344CC Management.exe:004344CC _ZNSaIiED1Ev allocator.h:103
0043642F Management.exe:0043642F _ZNSaIiED1Ev allocator.h:103
00434C18 Management.exe:00434C18 _ZNSaIiED1Ev allocator.h:103
00434B89 Management.exe:00434B89 _ZNSaIiED1Ev allocator.h:103
0041BBE6 Management.exe:0041BBE6 _Z14SetTitleWindowP6HWND struct.h:238
0041C9D3 Management.exe:0041C9D3 _Z15MDIChildWndProcP6HWND__jjl main.cpp:296
77801A10 USER32.dll:77801A10 GetMessageW
77803123 USER32.dll:77803123 GetWindow
77801C03 USER32.dll:77801C03 GetMessageW
777F8562 USER32.dll:777F8562 GetThreadDesktop
77D80E6E ntdll.dll:77D80E6E KiUserCallbackDispatcher
777F848B USER32.dll:777F848B GetThreadDesktop
777ED7F9 USER32.dll:777ED7F9 CreateWindowExA
778117A9 USER32.dll:778117A9 VkKeyScanExA
7781CDC6 USER32.dll:7781CDC6 GetPropA
77801A10 USER32.dll:77801A10 GetMessageW
77801AE8 USER32.dll:77801AE8 GetMessageW
7780286A USER32.dll:7780286A GetDesktopWindow
777ED93C USER32.dll:777ED93C SendMessageA
0041BD24 Management.exe:0041BD24 _Z17CreateNewMDIChildP6HWND main.cpp:104
0040314E Management.exe:0040314E _Z10Dlg_elencoP6HWND__jjl dlg_elenco.cpp:205
0041C335 Management.exe:0041C335 _Z7WndProcP6HWND__jjl main.cpp:200
77801A10 USER32.dll:77801A10 GetMessageW
77801AE8 USER32.dll:77801AE8 GetMessageW
7780286A USER32.dll:7780286A GetDesktopWindow
77802BBA USER32.dll:77802BBA SendMessageW
734A2A02 COMCTL32.DLL:734A2A02 CreateToolbar
734620E6 COMCTL32.DLL:734620E6 Ordinal301
77801A10 USER32.dll:77801A10 GetMessageW
77801AE8 USER32.dll:77801AE8 GetMessageW
77802A47 USER32.dll:77802A47 IsWindow
777F3C8A USER32.dll:777F3C8A DispatchMessageA
0041E115 Management.exe:0041E115 WinMain main.cpp:520
0042FADA Management.exe:0042FADA
00401237 Management.exe:00401237
004012A8 Management.exe:004012A8
773A3833 kernel32.dll:773A3833 BaseThreadInitThunk
77D5A9BD ntdll.dll:77D5A9BD LdrInitializeThunk
se invece appendo di seguito nello stesso file valori statici (cosa che non posso fare perchè i valori sono presenti
in win diverse ed in tempi divesi ed ogni volta sono diversi) non ho questo problema.
come posso risolvere ????