From f8c7de54eaf3e9165e41f212a13dd794ce7063a9 Mon Sep 17 00:00:00 2001 From: Lincoln Ramsay Date: Tue, 21 Apr 2009 16:33:04 +1000 Subject: Missing debug .rc file with a clean shadow build When generating Windows Makefiles, qmake writes out a .rc file for each of debug and release (unless you've limited to just one build type). When doing a clean shadow build, the first .rc file is written into a directory that does not exist but the code was not handling the error case. The fix does 2 things. 1) Attempt to create the destination directory if we can't write the file. 2) Die with an error if we still can't write the file after doing #1. Reviewed-by: Marius Storm-Olsen --- qmake/generators/win32/winmakefile.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 60a27be..87f55cf 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -432,9 +432,21 @@ void Win32MakefileGenerator::processRcFileVar() writeRcFile = rcFile.readAll() != rcString; rcFile.close(); } - if (writeRcFile && rcFile.open(QFile::WriteOnly)) { - rcFile.write(rcString); - rcFile.close(); + if (writeRcFile) { + bool ok; + ok = rcFile.open(QFile::WriteOnly); + if (!ok) { + // The file can't be opened... try creating the containing + // directory first (needed for clean shadow builds) + QDir().mkpath(QFileInfo(rcFile).path()); + ok = rcFile.open(QFile::WriteOnly); + } + if (!ok) { + ::fprintf(stderr, "Cannot open for writing: %s", rcFile.fileName().toLatin1().constData()); + ::exit(1); + } + rcFile.write(rcString); + rcFile.close(); } if (project->values("QMAKE_WRITE_DEFAULT_RC").isEmpty()) project->values("RC_FILE").insert(0, rcFile.fileName()); -- cgit v0.12