Changeset 561 for trunk/src/tools/idc


Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/tools/idc/main.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the tools applications of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4141
    4242#include <QFile>
    43 #include <QSysInfo>
    4443#include <QProcess>
    4544#include <QLibraryInfo>
     
    5150static QString quotePath(const QString &s)
    5251{
    53     if (!s.startsWith(QLatin1String("\"")) && s.contains(QLatin1Char(' ')))
    54         return QLatin1String("\"") + s + QLatin1String("\"");
     52    if (!s.startsWith(QLatin1)) && s.contains(QLatin1Char(' ')))
     53        return QLatin1);
    5554    return s;
    5655}
     
    8887static bool attachTypeLibrary(const QString &applicationName, int resource, const QByteArray &data, QString *errorMessage)
    8988{
    90     HANDLE hExe = 0;
    91     QT_WA({
    92         TCHAR *resourceName = MAKEINTRESOURCEW(resource);
    93         hExe = BeginUpdateResourceW((TCHAR*)applicationName.utf16(), false);
    94         if (hExe == 0) {
    95             if (errorMessage)
    96                 *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not open file.").arg(applicationName);
    97             return false;
    98         }
    99         if (!UpdateResourceW(hExe,L"TYPELIB",resourceName,0,(void*)data.data(),data.count())) {
    100             EndUpdateResource(hExe, true);
    101             if (errorMessage)
    102                 *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not update file.").arg(applicationName);
    103             return false;
    104         }
    105     }, {
    106         char *resourceName = MAKEINTRESOURCEA(resource);
    107         hExe = BeginUpdateResourceA(applicationName.toLocal8Bit(), false);
    108         if (hExe == 0) {
    109             if (errorMessage)
    110                 *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not open file.").arg(applicationName);
    111             return false;
    112         }
    113         if (!UpdateResourceA(hExe,"TYPELIB",resourceName,0,(void*)data.data(),data.count())) {
    114             EndUpdateResource(hExe, true);
    115             if (errorMessage)
    116                 *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not update file.").arg(applicationName);
    117             return false;
    118         }
    119     });
    120    
     89    HANDLE hExe = BeginUpdateResource((const wchar_t *)applicationName.utf16(), false);
     90    if (hExe == 0) {
     91        if (errorMessage)
     92            *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not open file.").arg(applicationName);
     93        return false;
     94    }
     95    if (!UpdateResource(hExe, L"TYPELIB", MAKEINTRESOURCE(resource), 0, (void*)data.data(), data.count())) {
     96        EndUpdateResource(hExe, true);
     97        if (errorMessage)
     98            *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not update file.").arg(applicationName);
     99        return false;
     100    }
     101
    121102    if (!EndUpdateResource(hExe,false)) {
    122103        if (errorMessage)
     
    136117        ok = runWithQtInEnvironment(quotePath(input) + QLatin1String(" -regserver"));
    137118    } else {
    138         HMODULE hdll = 0;
    139         QT_WA({
    140             hdll = LoadLibraryW((TCHAR*)input.utf16());
    141         }, {
    142             hdll = LoadLibraryA(input.toLocal8Bit());
    143         });
     119        HMODULE hdll = LoadLibrary((const wchar_t *)input.utf16());
    144120        if (!hdll) {
    145121            fprintf(stderr, "Couldn't load library file %s\n", (const char*)input.toLocal8Bit().data());
     
    163139        ok = runWithQtInEnvironment(quotePath(input) + QLatin1String(" -unregserver"));
    164140    } else {
    165         HMODULE hdll = 0;
    166         QT_WA({
    167             hdll = LoadLibraryW((TCHAR*)input.utf16());
    168         }, {
    169             hdll = LoadLibraryA(input.toLocal8Bit());
    170         });
     141        HMODULE hdll = LoadLibrary((const wchar_t *)input.utf16());
    171142        if (!hdll) {
    172143            fprintf(stderr, "Couldn't load library file %s\n", (const char*)input.toLocal8Bit().data());
     
    192163            res = S_OK;
    193164    } else {
    194         HMODULE hdll = 0;
    195         QT_WA({
    196             hdll = LoadLibraryW((TCHAR*)input.utf16());
    197         }, {
    198             hdll = LoadLibraryA(input.toLocal8Bit());
    199         });
     165        HMODULE hdll = LoadLibrary((const wchar_t *)input.utf16());
    200166        if (!hdll) {
    201167            fprintf(stderr, "Couldn't load library file %s\n", (const char*)input.toLocal8Bit().data());
     
    255221                version = QLatin1String(argv[i]);
    256222        } else if (p == QLatin1String("/tlb") || p == QLatin1String("-tlb")) {
    257             if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)
    258                 fprintf(stderr, "IDC requires Windows NT/2000/XP!\n");
    259            
    260223            ++i;
    261224            if (i > argc) {
     
    283246            return 0;
    284247        } else if (p[0] == QLatin1Char('/') || p[0] == QLatin1Char('-')) {
    285             error = QLatin1String("Unknown option \"") + p + QLatin1String("\"");
     248            error = QLatin1String("Unknown option \"") + p + QLatin1);
    286249            break;
    287250        } else {
     
    332295        case S_OK:
    333296            break;
     297
     298
     299
    334300        case -1:
    335301            fprintf(stderr, "Couldn't open %s for writing!\n", (const char*)idlfile.toLocal8Bit().data());
Note: See TracChangeset for help on using the changeset viewer.