QDir::mkpath and QImage::save on msvc2010 Release Build
I am using Qdir mkpath(dir) and QImage::save to save .png images. But on release mode the program doesnt create some folders nor save images even though it does on debug. But it creates some of folders I wanted to create.
And my code is here:
@ bool check_dir(QString qsDir)
bool create_dir(QString qsDir)
/* absolute path is necessary since mkpath works weird otherwise (2 dirs are created instead of one) */ if (fi.isRelative()) qsDir = fi.absoluteFilePath(); if (check_dir(qsDir)) return true; QDir dir(qsDir); return dir.mkpath(qsDir);
create_dir always return true.
I am using Qt 4.8.2 for release qmain.lib, QtCore4.lib, QtGui4.lib and with qmaind.lib, QtCored4.lib, QtGuid4.lib on debug
Could you please help me to fix this ?
Welcome to devnet,
Kindly use "code wrapping":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01 for your code, so that it is easily readable. Use @-tags for your code while posting.
I have found out what was wrong. If you are using assert you should drop NDEBUG from Release - Preprocessor options =)
Be aware that this is true for other debug instructions as well, like Q_ASSERT, Q_ASSERT_X and Q_CHECK_PTR, as they are removed in release builds (or more specifically when QT_NO_DEBUG is defined).
Be sure to never place instructions within such macros that could cause any side-effects.
// WRONG, removed in release build, uninitialized ptr
Q_CHECK_PTR(ptr = new char[size]);
ptr = new char[size];