Bonjour à tous,
Voila j'ai de manière assez aléatoire des crashs sur les lignes comportant l’opérateur<< de std::ofstream.
Je doit écrire dans un fichier temporaire certaines donnés, puis ce fichier temporaire et relu par le soft qui traite les données au fur qui sont mise dans un fichier final avant de supprimer le fichier temporaire sachant que ces actions sont répété en boucle pendant un certain temps. Cela me permet de traiter zone après zone mes informations.
Or de manière tout a fait aléatoire d'un coup je ne peux plus supprimer mon fichier temporaire puis même si j'écrase le contenu de mon fichier au bout d'un moment je ne peut plus écrire dans mon fichier final . je reçois l'erreur : <blockquote>The inferior stopped because it triggered an exceptions. Stopped in thread 11 by : Exception at 0x7ffb78a841es, code: 0x0000005: write acces violation at 0x1, flag= 0x0
lorsque je passe par la ligne suivante:
flux << "1vv10.0" << endl; // ligne du crash
pour information j'utilise Qtcreator avec QT 5.2.1
voici ma fonction entière :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| void Remplissage::redactionFichier(QMatrix4x4 transfo, std::ofstream &flux, std::map<double, std::vector<double> > &intersection)
{
bool aller = true;
for (std::map<double, std::vector<double>>::iterator it = intersection.begin(); it != intersection.end(); ++it)
{
if (annulation)
return ;
unsigned int nbPoint = (unsigned int)it->second.size();
if (nbPoint > 1)
{
sort(it->second.begin(), it->second.end());
int nbTrajSupprimer = VerifTrajTropCourte(it->second);
double axeDetection = it->first;
nbPoint = (unsigned int)it->second.size();
if ( nbPoint <2)
{
qDebug() << "Supression de la trajectoire entière";
continue;
}
unsigned int nbPointParTraj = 500;
unsigned int nbTrajectoire = ceil((static_cast<double>(nbPoint)/ static_cast<double>(nbPointParTraj)));
unsigned int nbPointDejaLu = 0;
for (unsigned int n = 0; n < nbTrajectoire; ++n)
{
if (annulation)
return ;
unsigned int nbPoint_TrajCourante = qMin(nbPoint-nbPointDejaLu,nbPointParTraj);
double coordDebutTrajectoire = 0.0;
double coordFinTrajectoire = 0.0;
if (aller)
{
coordDebutTrajectoire = it->second[nbPointDejaLu] - stabDebut;
coordFinTrajectoire = it->second[nbPointDejaLu + nbPoint_TrajCourante - 1] + stabFin;
}
else
{
coordFinTrajectoire = it->second[nbPointDejaLu] - stabFin;
coordDebutTrajectoire = it->second[nbPointDejaLu + nbPoint_TrajCourante - 1] + stabDebut;
}
try
{
if (direction == HORIZONTAL)
flux << "[FSCX]" << std::endl; //ligne qui crash
else if ( direction == VERTICALE)
flux << "[FSCY]" << endl;
else
{
qDebug() << "Combinaison Impossible";
continue;
}
flux << "Points " << nbPoint_TrajCourante;
for (unsigned int indicePoints = 0; indicePoints < nbPoint_TrajCourante; ++indicePoints)
{
double value = 0.0;
if (aller)
value = it->second[nbPointDejaLu + indicePoints];
else
value = it->second[nbPoint - (nbPointDejaLu + indicePoints + indicePoints + 1)];
flux << " " << QString().sprintf("%.6f", value).toLatin1().constData();
}
flux << endl;
flux << "[END]" << endl;
if ( nbPoint_TrajCourante<500)
nbPointDejaLu = 0;
else
nbPointDejaLu += nbPoint_TrajCourante;
}
catch (...)
{
qDebug() << "Crash a déterminer"
}
}
}
}
} |
Partager