Parcourir la source

Fix warnings in Libs/Core.

Change deprecated methods using #ifdef Q_OS_WIN32.
Resolve conversion from 'size_t' to 'int' warnings.
Michael Jeulin-L il y a 13 ans
Parent
commit
e6c532a61d
2 fichiers modifiés avec 13 ajouts et 4 suppressions
  1. 3 3
      Libs/Core/ctkDependencyGraph.cpp
  2. 10 1
      Libs/Core/ctkErrorLogFDMessageHandler.cpp

+ 3 - 3
Libs/Core/ctkDependencyGraph.cpp

@@ -367,7 +367,7 @@ int ctkDependencyGraphPrivate::subgraphSize(int rootId)
   std::set<int> vertices;
   vertices.insert(rootId);
   this->subgraphSizeRec(rootId, vertices);
-  return vertices.size();
+  return static_cast<int>(vertices.size());
 }
 
 void ctkDependencyGraphPrivate::subgraphInsert(
@@ -396,7 +396,7 @@ int ctkDependencyGraphPrivate::getOrGenerateSubgraphId(
   int subgraphId = -1;
   if (!mapContainsKey<int, int>(globalIdToSubgraph,globalId))
     {
-    subgraphId = globalIdToSubgraph.size() + 1;
+    subgraphId = static_cast<int>(globalIdToSubgraph.size()) + 1;
     globalIdToSubgraph[globalId] = subgraphId;
     subgraphIdToGlobal[subgraphId] = globalId;
     }
@@ -607,7 +607,7 @@ void ctkDependencyGraph::insertEdge(int from, int to)
   assert(to > 0 && to <= d_ptr->NVertices);
   
   // resize if needed
-  int capacity = d_ptr->Edges[from]->capacity();
+  size_t capacity = d_ptr->Edges[from]->capacity();
   if (d_ptr->OutDegree[from] > capacity)
     {
     d_ptr->Edges[from]->resize(capacity + capacity * 0.3);

+ 10 - 1
Libs/Core/ctkErrorLogFDMessageHandler.cpp

@@ -110,11 +110,12 @@ void ctkFDHandler::setEnabled(bool value)
 #ifdef Q_OS_WIN32
     this->SavedFDNumber = _dup(_fileno(this->terminalOutputFile()));
     _dup2(this->Pipe[1], _fileno(this->terminalOutputFile()));
+    _close(this->Pipe[1]);
 #else
     this->SavedFDNumber = dup(fileno(this->terminalOutputFile()));
     dup2(this->Pipe[1], fileno(this->terminalOutputFile()));
-#endif
     close(this->Pipe[1]);
+#endif
 
     // Start polling thread
     this->start();
@@ -142,7 +143,11 @@ void ctkFDHandler::setEnabled(bool value)
     clearerr(this->terminalOutputFile());
     fsetpos(this->terminalOutputFile(), &this->SavedFDPos);
 
+#ifdef Q_OS_WIN32
+    this->SavedFDNumber = _fileno(this->terminalOutputFile());
+#else
     this->SavedFDNumber = fileno(this->terminalOutputFile());
+#endif
     }
 
   ctkErrorLogTerminalOutput * terminalOutput =
@@ -164,7 +169,11 @@ void ctkFDHandler::run()
     QString line;
     while(c != '\n')
       {
+#ifdef Q_OS_WIN32
+      _read(this->Pipe[0], &c, 1); // When used with pipe, read() is blocking
+#else
       read(this->Pipe[0], &c, 1); // When used with pipe, read() is blocking
+#endif
       if (c != '\n')
         {
         line += c;