« first day (403 days earlier)      last day (2449 days later) » 

10:52 AM
Why: std::vector<int>(a); is same as: std::vector<int> a;
 
nwp
Because adding useless parenthesis usually doesn't do anything.
 
I thought parenthesis were for expressions
 
11:26 AM
You can thank C for that.
 
"thank"
 
We still introduce strange-looking things even to this day.
 
@Horttanainen consider that a int (*a)[20] is a pointer to array of 20 int
 
thank C in 3 seconds or get forever segmentation error
 
Like auto [a, b]{lol};
 
11:28 AM
Guys I already found an answer on SO
 
12:04 PM
17 messages moved from Lounge<C++>
 
nwp
@LandonZeKepitelOfGreytBritn Decide who can call runRecognitionScript. You can choose the GUI thread, meaning you should assert that you are currently in the GUI thread when the constructor runs (because that's where the QProcess is created) and another assert inside runRecognitionScript. Or you do the same with the worker thread. Or you decide that anyone can call runRecognitionScript because runRecognitionScript will automatically switch to the right thread when called from the wrong thread.
 
Actually I found a workaround :) I think I understood the issue
 
Famous last words
 
The issue is as you said (if I understood you correctly): when instantiating my class before moving it to the new workerthread. The constructor of QProcess is being called as well. The Qprocess p now belongs to the (let s call it for now) mainthread. Once I move to the workerthread and execute a function there. The process p belongs to the mainthread and I therefor cannot access it anymore from my workerthread.
solution which I used: create a dynamic QProcess p using new inside the workerthread.
rather that declaring QProcess p as a class member. @nwp ^
 
nwp
6 messages moved to Trash can
 
12:11 PM
@nwp Hmm. That note still stands IMO
 
nwp
@LandonZeKepitelOfGreytBritn You can also use moveToThread. new is evil.
 
found the workaround 40 minuts ago
@nwp well that s what I initially did (see my links above), but that didn't really work.
 
nwp
@sehe I don't know what "it" refers to in that message, but I'm fairly sure it is not related to a C++ question. Can you recover stuff from bin?
 
@nwp most of Qt's idiom stem from the OOP heydays so they somwhat expect you to use raw new and pointers for QObjects
and then use the parent-child to track ownership
 
@nwp I can, but I won't. Not important enough
 
nwp
12:22 PM
@ratchetfreak I know. It is probably the biggest issue of Qt. But at least in this case it is avoidable.
 
@nwp you think it is bad to use too much new?
 
any new is bad
 
that s what I was taught to do in Qt multiple years back
at uni
@sehe would you mind explaining why any new is bad? If it were on an embedded device I would totally understand and agree, but on a desktop environment...
 
665
Q: Why should C++ programmers minimize use of 'new'?

bitgardenI stumbled upon Stack Overflow question Memory leak with std::string when using std::list<std::string>, and one of the comments says this: Stop using new so much. I can't see any reason you used new anywhere you did. You can create objects by value in C++ and it's one of the huge advantag...

 
nwp
new is bad because you have to remember to delete which is unnecessarily difficult. But Qt forces you to do it because it used a non-standard ownership model, which sucks a lot.
 
12:28 PM
+1
 
@nwp if C++ would have a garbage collector using new wouldn t be an issue I infer.
 
@LandonZeKepitelOfGreytBritn many small allocations is bad by itself
 
btw is it really such a big issue if you forget to delete it on a desktop ?
@ratchetfreak why?
 
nwp
@LandonZeKepitelOfGreytBritn Some argue that C++ does have a garbage collector. A typical implementation of a garbage collector is to do reference counting on pointers. That's what std::shared_ptr does. It is just that C++ allows you not to use the garbage collector which is usually a bad decision.
 
@LandonZeKepitelOfGreytBritn memory access (a cache miss) is pretty bad
prefer to keep data that is used together localized in memory
 
12:31 PM
HERP DERP GC
 
nwp
@LandonZeKepitelOfGreytBritn Depends on if the destructor does something useful. Sometimes it finishes writing a file and not doing that leaves you with garbage data.
 
@LandonZeKepitelOfGreytBritn GC comes with its own issues
@LandonZeKepitelOfGreytBritn please. stay away from c++
 
@LandonZeKepitelOfGreytBritn C++ doesn't need GC nor new because it has RAII
 
12:52 PM
hey guys, I'm having a "cant convert from const Object* to Object* const" problem which I cant understand why its happening. Heres a ~30 lines snippet and I'd appreciate if someone can help! pastebin.com/KjaNu28Z
 
@ratchetfreak why? I understand what you mean, but I am trying to understand why exactly this is bad.
on an EE level I almost don't see why this would be bad. And on a higher level if cpp has the "new" keyword it must be there for a reason.
 
The reason is new is the late 80s and std::unique_ptr is early 10s, and Qt is late 90s
@YvesHenri one is a pointer to a constant object and the other is a constant pointer to an non-constant object
you can't convert from one to another; go figure
 
I'm sorry, i'm completely lost. How should the other constructor be in order to accomplish both scenarios
 
@YvesHenri the keyword const always to the word/symbol on its left side. If there is nothing on its left side... only one thing left to do: look to the right of the keyword
 
@YvesHenri The problem can be reduced to "you can't call non-const member function on a constant object"
 
nwp
1:01 PM
Changing Qt's interface to take std::unique_ptrs when it takes ownership would make sense. It's probably even doable without that much effort and at least communicates what is happening.
But then people would need to understand std::unique_ptr and std::move and that is probably beyond what they want to expect from an average Qt user.
 
the second param expects a const* Object and this is whats passed to it. why its complaining about Object* const when I clearly have a const Object*? thats the question
 
const X* and X* const are different
 
I know, but there isnt any X* const in the example provided. is there?
(the compiler says so, but I cant figure it out)
 
@YvesHenri const Instance is (for Instance = Object*)
 
@nwp except changing the parent is done from the owned object rather than the owning object
 
1:05 PM
@milleniumbug were getting to the point... if Instance is X*, then we have const X*, not X* const
 
yeah except this is not how it works
 
is it how that works
 
the type parameters and typedefs aren't expanded lexically
 
nwp
@ratchetfreak I think it would still be possible to implement that.
 
where can I find more info about this subject, @milleniumbug
 
nwp
1:08 PM
deleteing an object that was given to Qt as a unique_ptr is allowed even though the interface doesn't communicate that. Not sure how big of a problem that is.
 
it's as if you expected X*2 to be equal to 6 when X == 2+2, because 2+2*2 == 6
 
this is completely new to me
removing the using's seems to do what I was expecting/wanting
 
 
8 hours later…
9:00 PM
Please help me, QTextToSpeech problem stackoverflow.com/questions/44861924/…
 
nwp
You are supposed to ask a question before begging.
 

« first day (403 days earlier)      last day (2449 days later) »