Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDir::mkpath and QImage::save on msvc2010 Release Build

QDir::mkpath and QImage::save on msvc2010 Release Build

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LifeSoldier
    wrote on last edited by
    #1

    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)
    {
    assert(!qsDir.isEmpty());
    QDir dir(qsDir);
    return dir.exists();
    }

    bool create_dir(QString qsDir)
    {
    QFileInfo fi(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 ?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sam
      wrote on last edited by
      #2

      Hi,

      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.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        LifeSoldier
        wrote on last edited by
        #3

        I have found out what was wrong. If you are using assert you should drop NDEBUG from Release - Preprocessor options =)

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          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]);

          // RIGHT
          ptr = new char[size];
          Q_CHECK_PTR(ptr);
          @

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved