QVector is written in such a way that the allocated memory is checked using the macro Q_CHECK_PTR. In my program, with unsuccessful allocation Q_CHECK_PTR calls qFatal, which terminates the program. I do not like this behavior, I want to get an exception. In the source code, Q_CHECK_PTR looks like this:

So, there is a way to call Q_CHECK_PTR exception version. But how ? I tried to compile with CONFIG += exceptions . But it doesnt't help.
WIN 7 x32 , mingw-32

]]>https://forum.qt.io/topic/79308/how-disable-qt_no_exceptionsRSS for NodeThu, 22 Feb 2018 05:18:42 GMTTue, 16 May 2017 10:38:55 GMT60QVector is written in such a way that the allocated memory is checked using the macro Q_CHECK_PTR. In my program, with unsuccessful allocation Q_CHECK_PTR calls qFatal, which terminates the program. I do not like this behavior, I want to get an exception. In the source code, Q_CHECK_PTR looks like this:

to compile what? You would need to compile Qt itself after setting QT_NO_EXCEPTIONS=0.
This is Qt code and #ifdef is handled at compile time.

Thanks you for the answer. How can i do that? Where should i set QT_NO_EXCEPTIONS = 0? Can you give some link with example?

]]>https://forum.qt.io/post/393784https://forum.qt.io/post/393784Tue, 16 May 2017 10:58:49 GMT@bronstein87 You will need to build Qt. Do you really want to do this? Why is the default behaviour of QVector an issue for you? Qt does not use C++ exceptions. What do you want to do if you cannot allocate memory any-more?
I think you would need to pass "-UQT_NO_EXCEPTIONS" parameter to configure command.
]]>https://forum.qt.io/post/393785https://forum.qt.io/post/393785Tue, 16 May 2017 11:10:04 GMT@jsulm yes, i do. i need to avoid abort() which calls Q_CHECK_PTR version with defined QT_NO_EXCEPTIONS.

What do you want to do if you cannot allocate memory any-more?

I will clear part of used memory in catch() and continue to work.
And if developers added version with exceptions, why it's bad to use it?

]]>https://forum.qt.io/post/393788https://forum.qt.io/post/393788Tue, 16 May 2017 11:13:19 GMT@bronstein87 Well, then download Qt source code and build it. Don't forget to pass -UQT_NO_EXCEPTIONS as parameter to configure.
"I will clear part of used memory in catch() and continue to work." - how will you decide which memory to free and how are you going to make sure your app does not crash because you freed some memory which is actually needed somewhere in your app?
"And if developers added version with exceptions, why it's bad to use it?" - I did not say it's bad, I said that Qt by default does not use C++ exceptions. Even if you activate exceptions Qt will only use few of them.
]]>https://forum.qt.io/post/393790https://forum.qt.io/post/393790Tue, 16 May 2017 11:18:06 GMT@jsulm

how will you decide which memory to free and how are you going to make sure your app does not crash because you freed some memory which is actually needed somewhere in your app?

My program plots a large number of graphs for a large amount of data. I'll just clean the charts already plot.

]]>https://forum.qt.io/post/393791https://forum.qt.io/post/393791Tue, 16 May 2017 11:21:32 GMT@bronstein87 OK. I hope it will work: if any memory is reserved during this clean up you will get out-of-memory exception again (or it will crash).
]]>https://forum.qt.io/post/393792https://forum.qt.io/post/393792Tue, 16 May 2017 11:26:37 GMT