Salome HOME
Some corrections related to using UNICODE. rnv/unicode
authorrnv <rnv@opencascade.com>
Thu, 27 Sep 2018 11:25:21 +0000 (14:25 +0300)
committerrnv <rnv@opencascade.com>
Thu, 27 Sep 2018 11:25:21 +0000 (14:25 +0300)
src/CAM/CAM_Application.cxx
src/GLViewer/GLViewer_BaseObjects.cxx
src/GLViewer/GLViewer_Viewer2d.cxx

index 00da564614266962cee2f7afc9c1d1b1a7cce15a..247270583a8912845a101c3ea226683849f18d87 100755 (executable)
@@ -320,14 +320,17 @@ CAM_Module* CAM_Application::loadModule( const QString& modName, const bool show
   GET_VERSION_FUNC getVersion = 0;
 
 #ifdef WIN32
-
 #ifdef UNICODE
   LPTSTR str_libname = new TCHAR[libName.length() + 1];
   str_libname[libName.toWCharArray(str_libname)] = '\0';
-#else  
-  LPTSTR str_libname = libName.toLatin1().constData();
+#else
+  QByteArray arr = libName.toLatin1();
+  LPTSTR str_libname = arr.constData();
 #endif
   HINSTANCE modLib = ::LoadLibrary( str_libname );
+#ifdef UNICODE
+  delete str_libname;
+#endif
   if ( !modLib )
   {
     LPVOID lpMsgBuf;
index 6e65422f294b93b43d9d748e7d0a80dc55018a7a..e1193a53810746fde50d5408645fca8fd7799380 100644 (file)
@@ -1469,9 +1469,13 @@ bool GLViewer_TextObject::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerC
        LPTSTR str = new TCHAR[aText.length() + 1];
        str[aText.toWCharArray(str)] = '\0';
 #else  
-       LPTSTR str = aText.toLatin1().constData();
+       QByteArray arr = FileName.toLatin1();
+       LPTSTR str = arr.constData();
 #endif
     TextOut( dc, x, y, str, aText.length() );
+#ifdef UNICODE
+        delete str;
+#endif
 
     SelectObject ( dc, old1 );
     SelectObject ( dc, old2 );
index b11c4d710a0e62b2d758b67d0cdcb53dd1762dc2..62963722bd202919af293d70dffdafce6c36f449 100644 (file)
@@ -794,15 +794,19 @@ bool GLViewer_Viewer2d::translateTo( VectorFileType aType, QString FileName, Pap
         HDC bitDC = CreateCompatibleDC ( screen_dc ); //The context compatible with screen
 
 #ifdef UNICODE
-               LPTSTR str = new TCHAR[FileName.length() + 1];
-               str[FileName.toWCharArray(str)] = '\0';
-               LPTSTR empty = L"";
+       LPTSTR str = new TCHAR[FileName.length() + 1];
+       str[FileName.toWCharArray(str)] = '\0';
+       LPTSTR empty = L"";
 #else  
-               LPTSTR str = FileName.toLatin1().constData();
-               LPTSTR empty = "";
+       QByteArray arr = FileName.toLatin1();
+       LPTSTR str = arr.constData();
+       LPTSTR empty = "";
 #endif
 
         hMetaFileDC = CreateEnhMetaFile( bitDC, str, &r, empty );
+#ifdef UNICODE
+       delete str;
+#endif 
         SetMapMode( hMetaFileDC, MM_HIMETRIC );
         SetWindowOrgEx( hMetaFileDC, 0, r.bottom, NULL );
         HRGN ClipRgn = CreateRectRgn( 0, 0, AW, AH );
@@ -817,7 +821,7 @@ bool GLViewer_Viewer2d::translateTo( VectorFileType aType, QString FileName, Pap
         ReleaseDC( 0, screen_dc );
         DeleteDC( bitDC );
 
-        aCurVP->getGLWidget()->translateBackgroundToEMF( hMetaFileDC, &aViewerCS, &aPaperCS );
+        aCurVP->getGLWidget()->translateBackgroundToEMF( hMetaFileDC, &aViewerCS, &aPaperCS ); 
     }
 #endif