Mentions légales du service

Skip to content
Snippets Groups Projects
Commit bf1cd97e authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Merge branch 'fix-buggy-commit-parsing-dates' into 'master'

Fix previous commit which broke date parsing & palette creation

Hello,

I fixed the previous commit (a73852cb), which was maybe pushed a little bit too fast ! :smiley: 

Two things where broken (just by opening a simple trace file):
- date parsing didn't work anymore
- a `delete` lead to a segfault

Philippe.

See merge request !14
parents 1642ea48 328662f6
No related branches found
No related tags found
1 merge request!14Fix previous commit which broke date parsing & palette creation
Pipeline #79921 passed
......@@ -286,16 +286,18 @@ void Session::get_palettes_name(const std::string &type, QStringList &list) {
}
Palette *Session::get_palette(const std::string &type, const std::string &palette_name) {
Palette *p = NULL;
Palette *p, **where_from;
if( type == "palette" ) {
p = _palettes_state;
where_from = &_palettes_state;
}
else if( type == "link_types" ) {
p = _palettes_link;
where_from = &_palettes_link;
}
else if( type == "event_types" ) {
p = _palettes_event;
where_from = &_palettes_event;
}
if(!p || p->get_name() != palette_name) {
......@@ -304,6 +306,7 @@ Palette *Session::get_palette(const std::string &type, const std::string &palett
QMap <QString, QVariant> qmap = S->value(QString::fromStdString(type+"/"+palette_name+"/map")).toMap();
p = new Palette(string(type+"/"+palette_name));
*where_from = p;
for(QMap<QString, QVariant>::const_iterator it = qmap.constBegin() ;
it != qmap.constEnd() ; ++ it) {
const QColor qc = it.value().value<QColor>();
......
......@@ -59,7 +59,7 @@ using namespace std;
bool convert_to_double(const std::string &arg, double *val) {
unsigned int nb_read;
// Try to convert first in the current locale
sscanf(arg.c_str(), "%lf%u", val, &nb_read);
sscanf(arg.c_str(), "%lf%n", val, &nb_read);
if(nb_read == arg.size()) {
return true; // It is the good format
......@@ -88,7 +88,7 @@ bool convert_to_double(const std::string &arg, double *val) {
}
// Reads the value in the new locale
sscanf(arg.c_str(), "%lf%u", val, &nb_read);
sscanf(arg.c_str(), "%lf%n", val, &nb_read);
return nb_read == arg.size();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment