Search found 199 matches

by alys666
Mon Jun 24, 2019 7:32 pm
Forum: C++ Development
Topic: Char Array Is Getting Corrupted
Replies: 16
Views: 432

Re: Char Array Is Getting Corrupted

I think that is what the user over in cplusplus.com forums is trying to tell me, that I need to call delete[] objectData; in the constructor to prevent memory leaks: ResourceObject::ResourceObject(unsigned char* data, unsigned int data_size) { if (objectData) { delete[] objectData; objectData = NUL...
by alys666
Mon Jun 24, 2019 2:44 pm
Forum: C++ Development
Topic: How to attach some user data to wxWindow?
Replies: 5
Views: 161

Re: How to attach some user data to wxWindow?

Hi, You shouldn't pass anything GUI-related to a secondary thread. Passing it there will imply usage and you can't use it inside the thread. ;-) Thank you. it's wrong. I can pass to secondary thread address of destination wxEventHandler and send him async events. it's how async messaging works in w...
by alys666
Mon Jun 24, 2019 10:59 am
Forum: C++ Development
Topic: Char Array Is Getting Corrupted
Replies: 16
Views: 432

Re: Char Array Is Getting Corrupted

If you can use std::vector<> - use std::vector<> . You write on C++ so you shouldn't avoid simple stuff just because you can do it. std:vector is a common container with access by index, which can be iterated via formal iterators, an can shrink and grow. it is used as part of high level algorithms ...
by alys666
Mon Jun 24, 2019 5:31 am
Forum: C++ Development
Topic: Char Array Is Getting Corrupted
Replies: 16
Views: 432

Re: Char Array Is Getting Corrupted

objectData = new unsigned char[data_size]; But it still didn't work. Let me know if I misunderstood you. yes. it's how you must implement this place, and don't use std::vector. uint8 *_data = new uint8[datasize]; memcpy(_data, ext_data, datasize); ... delete[] _data; ... if it is "not working", the...
by alys666
Sun Jun 23, 2019 6:03 pm
Forum: C++ Development
Topic: Char Array Is Getting Corrupted
Replies: 16
Views: 432

Re: Char Array Is Getting Corrupted

memcpy cannot copy only one byte.. if you didn't give 1 byte as size to copy.
in your case std::vector is excessive.
better to take an array by new[size], copy there, and do not forget to delete it by delete[].
by alys666
Sat Jun 22, 2019 8:47 pm
Forum: C++ Development
Topic: How to wxIsKindOf class check for a wxTextEntry derived classes?
Replies: 8
Views: 238

Re: How to wxIsKindOf class check for a wxTextEntry derived classes?

That is exactly what came to my mind, using like: bool wxHasTextEntry(const wxWindow *pWindow); and wxTextEntry *wxGetTextEntry(const wxWindow *pWindow); What I am struggling about is what kinda cast should I use!? wxDynamicCast or wxStaticCast ? TIA. you can use static_cast<SomeType *> if you are ...
by alys666
Sat Jun 22, 2019 8:48 am
Forum: C++ Development
Topic: How to attach some user data to wxWindow?
Replies: 5
Views: 161

Re: How to attach some user data to wxWindow?

i thought about mixing, but then i cannot give to secondary threads generic reference to custom classes instances as wxWindow*.
And i also thought about temporary name correction, kinda prefix it with '!'.
by alys666
Sat Jun 22, 2019 8:29 am
Forum: C++ Development
Topic: How to attach some user data to wxWindow?
Replies: 5
Views: 161

How to attach some user data to wxWindow?

in my case i have different custom panes which cannot be closed or deleted, while some thread is using them via sending async messages. the easiest way, i see - is an ability to attach some user data to any wxWindow, for example bool, meaning - can close/cannot close. so it would be a good feature t...
by alys666
Sat Jun 22, 2019 8:02 am
Forum: C++ Development
Topic: events, secondary threads & app remote control
Replies: 10
Views: 251

Re: events, secondary threads & app remote control

i do not recommend to use wxCommandEvent to be fired from user threads(it's just my IMHO) - it's events used by wxWidgets to be fired by wxWidgets controls... so if secondary thread fires them - he is simulating reaction of controls, and it makes things more complex. but wxThreadEvent is just a thin...
by alys666
Sat Jun 22, 2019 6:51 am
Forum: C++ Development
Topic: events, secondary threads & app remote control
Replies: 10
Views: 251

Re: events, secondary threads & app remote control

1. forget about static event tables - this style is old. use Bind(...) - dynamically attach/detach event handler 2. if you want the frame, handling events from secondary thread, you must say somewhere(for example in constructor) this->Bind(wxEVT_THREAD,&MyFrame::onAsyncThreadEvent,this); here you bi...
by alys666
Sat Jun 22, 2019 1:45 am
Forum: C++ Development
Topic: events, secondary threads & app remote control
Replies: 10
Views: 251

Re: events, secondary threads & app remote control

do not panic on strings given to events. you can clone given string manually, giving not actual string to event(if you are afraid - it won't be cloned) but clone it in place. not Event(...my_string...), but Event (...my_string.Clone()). also you must clone somehow any data, which could be shared bet...
by alys666
Sat Jun 22, 2019 1:26 am
Forum: C++ Development
Topic: Threaded Job/Queue Manager getting stuck?
Replies: 8
Views: 254

Re: Threaded Job/Queue Manager getting stuck?

Can anyone confirm the following? The complete Job/Queue Manager example provided by https://wiki.wxwidgets.org/Inter-Thread_and_Inter-Process_communication is actually thread unsafe because it uses wxCommandEvents to pass strings between threads? Furthermore, the Queue class's Report() method uses...
by alys666
Wed Jun 19, 2019 9:45 pm
Forum: C++ Development
Topic: wxAuiToolBar - delete separator
Replies: 7
Views: 157

Re: wxAuiToolBar - delete separator

yes, rando. your idea works well. ps. i discovered just now that actually it's an instance of wxToolBar, not wxAuiToolBar... :) but there is a the same problem. My old code uses wxToolbar, but since some time i switched to wxAuiToolbar... but can't understand serious difference for now, except of me...
by alys666
Wed Jun 19, 2019 9:24 pm
Forum: C++ Development
Topic: looking for EVT_TREE_SEL_CHANGING handler example
Replies: 5
Views: 146

Re: looking for EVT_TREE_SEL_CHANGING handler example

you must define your custom handler void myOnSelectionChanging(wxTreeEvent& event){ ... } and bind it to event wxEVT_TREE_SEL_CHANGING of the tree(tree is of wxEventHandler type because of inheritance) and do everything you need in there. current selection you can get inside this handler via this-> ...
by alys666
Wed Jun 19, 2019 8:00 pm
Forum: C++ Development
Topic: wxAuiToolBar - delete separator
Replies: 7
Views: 157

Re: wxAuiToolBar - delete separator

I usually clear the complete toolbar then rebuild it with the needed tools and layout as required. You can have a function to do that with an enum argument that lists your various layouts. Doing it that way produces easier to read and modify code down the road. in my case, I have a "stack like look...