Changeset 75
- Timestamp:
- Jul 9, 2009, 8:37:15 PM (16 years ago)
- Location:
- trunk/src/corelib/plugin
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/corelib/plugin/plugin.pri
r2 r75 20 20 } 21 21 22 23 24 25 22 26 unix { 23 27 SOURCES += plugin/qlibrary_unix.cpp -
trunk/src/corelib/plugin/qlibrary_os2.cpp
r63 r75 1 /*************************************************************************** *1 /*************************************************************************** 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** Contact: Qt Software Information ([email protected]) 5 6 5 7 ** 6 8 ** This file is part of the QtCore module of the Qt Toolkit. … … 47 49 #include "qdir.h" 48 50 49 #if defined(QT_NO_LIBRARY) && defined(Q_OS_WIN) 50 #undef QT_NO_LIBRARY 51 #pragma message("QT_NO_LIBRARY is not supported on Windows") 52 #endif 53 54 #include "qt_windows.h" 51 #ifndef QT_NO_LIBRARY 55 52 56 53 QT_BEGIN_NAMESPACE 57 54 58 extern QString qt_error_string(int code); 55 // provide human readable strings for common OS/2 DOS errors 56 // @todo make exported if needed anywhere else 57 static QString qt_os2_error_string(APIRET code) 58 { 59 // see qt_error_string() 60 61 const char *s = 0; 62 QString ret; 63 64 switch (code) { 65 case NO_ERROR: 66 return ret; 67 case ERROR_FILE_NOT_FOUND: 68 s = QT_TRANSLATE_NOOP("QIODevice", "File not found"); 69 break; 70 case ERROR_PATH_NOT_FOUND: 71 s = QT_TRANSLATE_NOOP("QIODevice", "Path not found"); 72 break; 73 case ERROR_TOO_MANY_OPEN_FILES: 74 return qt_error_string(EMFILE); 75 case ERROR_ACCESS_DENIED: 76 s = QT_TRANSLATE_NOOP("QIODevice", "Access denied"); 77 break; 78 case ERROR_SHARING_VIOLATION: 79 s = QT_TRANSLATE_NOOP("QIODevice", "Sharing violation"); 80 break; 81 default: 82 break; 83 } 84 85 if (s) 86 // ######## this breaks moc build currently 87 // ret = QCoreApplication::translate("QIODevice", s); 88 ret = QString::fromLatin1(s); 89 else 90 // ######## this breaks moc build currently 91 // ret = QString(QCoreApplication::translate("QIODevice","System error %1")).arg(code); 92 ret = QString::fromLatin1("System error %1").arg(code); 93 return ret; 94 } 59 95 60 96 bool QLibraryPrivate::load_sys() 61 97 { 62 #ifdef Q_OS_WINCE 63 QString attempt = QFileInfo(fileName).absoluteFilePath(); 64 #else 65 QString attempt = fileName; 66 #endif 98 pHnd = 0; 67 99 68 //avoid 'Bad Image' message box 69 UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); 70 QT_WA({ 71 pHnd = LoadLibraryW((TCHAR*)QDir::toNativeSeparators(attempt).utf16()); 72 } , { 73 pHnd = LoadLibraryA(QFile::encodeName(QDir::toNativeSeparators(attempt)).data()); 74 }); 75 76 if (pluginState != IsAPlugin) { 77 #if defined(Q_OS_WINCE) 78 if (!pHnd && ::GetLastError() == ERROR_MOD_NOT_FOUND) { 79 QString secondAttempt = fileName; 80 QT_WA({ 81 pHnd = LoadLibraryW((TCHAR*)QDir::toNativeSeparators(secondAttempt).utf16()); 82 } , { 83 pHnd = LoadLibraryA(QFile::encodeName(QDir::toNativeSeparators(secondAttempt)).data()); 84 }); 85 } 86 #endif 87 if (!pHnd && ::GetLastError() == ERROR_MOD_NOT_FOUND) { 88 attempt += QLatin1String(".dll"); 89 QT_WA({ 90 pHnd = LoadLibraryW((TCHAR*)QDir::toNativeSeparators(attempt).utf16()); 91 } , { 92 pHnd = LoadLibraryA(QFile::encodeName(QDir::toNativeSeparators(attempt)).data()); 93 }); 94 } 100 QByteArray attempt = QFile::encodeName(QDir::toNativeSeparators(fileName)); 101 102 APIRET rc; 103 char errModule[CCHMAXPATH] = { '\0' }; 104 rc = DosLoadModule(errModule, sizeof(errModule), attempt, &pHnd); 105 if (rc == ERROR_FILE_NOT_FOUND) { 106 attempt += ".DLL"; 107 rc = DosLoadModule(errModule, sizeof(errModule), attempt, &pHnd); 95 108 } 96 109 97 SetErrorMode(oldmode); 98 if (!pHnd) { 99 errorString = QLibrary::tr("Cannot load library %1: %2").arg(fileName).arg(qt_error_string()); 110 if (rc != NO_ERROR) { 111 errorString = QLibrary::tr("Cannot load library %1: %2") 112 .arg(fileName).arg(qt_os2_error_string(rc)); 113 if (*errModule != '\0') 114 errorString += QLibrary::tr(" (failed module: %1)").arg(errModule); 115 return false; 100 116 } 101 if (pHnd) { 102 errorString.clear(); 103 QT_WA({ 104 TCHAR buffer[MAX_PATH + 1]; 105 ::GetModuleFileNameW(pHnd, buffer, MAX_PATH); 106 attempt = QString::fromUtf16(reinterpret_cast<const ushort *>(&buffer)); 107 }, { 108 char buffer[MAX_PATH + 1]; 109 ::GetModuleFileNameA(pHnd, buffer, MAX_PATH); 110 attempt = QString::fromLocal8Bit(buffer); 111 }); 112 const QDir dir = QFileInfo(fileName).dir(); 113 const QString realfilename = attempt.mid(attempt.lastIndexOf(QLatin1Char('\\')) + 1); 114 if (dir.path() == QLatin1String(".")) 115 qualifiedFileName = realfilename; 116 else 117 qualifiedFileName = dir.filePath(realfilename); 118 } 119 return (pHnd != 0); 117 118 errorString.clear(); 119 rc = DosQueryModuleName(pHnd, sizeof(errModule), errModule); 120 Q_ASSERT(rc == NO_ERROR); 121 122 qualifiedFileName = QDir::fromNativeSeparators(QFile::decodeName(QByteArray(errModule))); 123 124 return true; 120 125 } 121 126 122 127 bool QLibraryPrivate::unload_sys() 123 128 { 124 if (!FreeLibrary(pHnd)) { 125 errorString = QLibrary::tr("Cannot unload library %1: %2").arg(fileName).arg(qt_error_string()); 129 APIRET rc = DosFreeModule(pHnd); 130 if (rc != NO_ERROR) { 131 errorString = QLibrary::tr("Cannot unload library %1: %2").arg(fileName).arg(qt_os2_error_string(rc)); 126 132 return false; 127 133 } … … 132 138 void* QLibraryPrivate::resolve_sys(const char* symbol) 133 139 { 134 #ifdef Q_OS_WINCE 135 void* address = (void*)GetProcAddress(pHnd, (const wchar_t*)QString::fromLatin1(symbol).utf16()); 136 #else 137 void* address = (void*)GetProcAddress(pHnd, symbol); 138 #endif 139 if (!address) { 140 void *address = 0; 141 APIRET rc = DosQueryProcAddr(pHnd, 0, symbol, (PFN*) &address); 142 if (rc != NO_ERROR) { 140 143 errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg( 141 QString::fromAscii(symbol)).arg(fileName).arg(qt_ error_string());144 QString::fromAscii(symbol)).arg(fileName).arg(qt_)); 142 145 } else { 143 146 errorString.clear(); … … 146 149 } 147 150 QT_END_NAMESPACE 151 152 -
trunk/src/corelib/plugin/qlibrary_p.h
r2 r75 54 54 // 55 55 56 #if def Q_WS_WIN56 #if 57 57 # include "QtCore/qt_windows.h" 58 59 58 60 #endif 59 61 #include "QtCore/qlibrary.h" … … 73 75 public: 74 76 75 #if def Q_WS_WIN77 #if 76 78 HINSTANCE 79 80 77 81 #else 78 82 void *
Note:
See TracChangeset
for help on using the changeset viewer.