From kde-commits Tue Feb 28 23:03:40 2017 From: Vincent Pinon Date: Tue, 28 Feb 2017 23:03:40 +0000 To: kde-commits Subject: [kdenlive] src/doc: Fix GCC warnings: fps switch logic (function still buggy) Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=148832303310523 Git commit 94f9c53ca49979dbb86cb238a2975c0c67a45a12 by Vincent Pinon. Committed on 28/02/2017 at 22:31. Pushed by vpinon into branch 'master'. Fix GCC warnings: fps switch logic (function still buggy) M +18 -30 src/doc/kdenlivedoc.cpp https://commits.kde.org/kdenlive/94f9c53ca49979dbb86cb238a2975c0c67a45a12 diff --git a/src/doc/kdenlivedoc.cpp b/src/doc/kdenlivedoc.cpp index 5d880698a..08b6e66e5 100644 --- a/src/doc/kdenlivedoc.cpp +++ b/src/doc/kdenlivedoc.cpp @@ -189,7 +189,7 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QString= &projectFolder, QUndoGro int errorPos =3D 0; line--; col =3D col - 2; - for (int j =3D 0; j < line && errorPos < playl= ist.length(); ++j) { + for (int k =3D 0; k < line && errorPos < playl= ist.length(); ++k) { errorPos =3D playlist.indexOf(QLatin1Char(= '\n'), errorPos); errorPos++; } @@ -439,7 +439,7 @@ QDomDocument KdenliveDoc::createEmptyDocument(const QLi= st &tracks) // The lower video track will receive composite transitions int lowestVideoTrack =3D -1; for (int i =3D 0; i < total; ++i) { - QDomElement playlist =3D doc.createElement(QStringLiteral("playlis= t")); + playlist =3D doc.createElement(QStringLiteral("playlist")); playlist.setAttribute(QStringLiteral("id"), QStringLiteral("playli= st") + QString::number(i + 1)); playlist.setAttribute(QStringLiteral("kdenlive:track_name"), track= s.at(i).trackName); if (tracks.at(i).type =3D=3D AudioTrack) { @@ -479,7 +479,7 @@ QDomDocument KdenliveDoc::createEmptyDocument(const QLi= st &tracks) QDomElement transition =3D doc.createElement(QStringLiteral("t= ransition")); transition.setAttribute(QStringLiteral("always_active"), QStri= ngLiteral("1")); = - QDomElement property =3D doc.createElement(QStringLiteral("pro= perty")); + property =3D doc.createElement(QStringLiteral("property")); property.setAttribute(QStringLiteral("name"), QStringLiteral("= mlt_service")); value =3D doc.createTextNode(QStringLiteral("mix")); property.appendChild(value); @@ -487,7 +487,7 @@ QDomDocument KdenliveDoc::createEmptyDocument(const QLi= st &tracks) = property =3D doc.createElement(QStringLiteral("property")); property.setAttribute(QStringLiteral("name"), QStringLiteral("= a_track")); - QDomText value =3D doc.createTextNode(QStringLiteral("0")); + value =3D doc.createTextNode(QStringLiteral("0")); property.appendChild(value); transition.appendChild(property); = @@ -1521,7 +1521,7 @@ void KdenliveDoc::updateProjectProfile(bool reloadPro= ducers) return; } emit updateFps(fpsChanged); - if (fpsChanged !=3D 1.0) { + if (qAbs(fpsChanged - 1.0) > 1e-6) { pCore->bin()->reloadAllProducers(); } } @@ -1605,34 +1605,22 @@ void KdenliveDoc::switchProfile(MltVideoProfile pro= file, const QString &id, cons // Check profile fps so that we don't end up with an fps =3D 30.00= 3 which would mess things up QString adjustMessage; double fps =3D (double)profile.frame_rate_num / profile.frame_rate= _den; - double fps_int; - double fps_frac =3D std::modf(fps, &fps_int); - if (fps_frac < 0.4) { - profile.frame_rate_num =3D (int) fps_int; + if (fps - ((int)fps) < 0.4) { + profile.frame_rate_num =3D fps; profile.frame_rate_den =3D 1; + } else if (qAbs(fps - 23.98) < 0.01) { + profile.frame_rate_num =3D 24000; + profile.frame_rate_den =3D 1001; + } else if (qAbs(fps - 29.97) < 0.01) { + profile.frame_rate_num =3D 30000; + profile.frame_rate_den =3D 1001; + } else if (qAbs(fps - 59.94) < 0.01) { + profile.frame_rate_num =3D 60000; + profile.frame_rate_den =3D 1001; } else { - // Check for 23.98, 29.97, 59.94 - if (fps_int =3D=3D 23.0) { - if (qAbs(fps - 23.98) < 0.01) { - profile.frame_rate_num =3D 24000; - profile.frame_rate_den =3D 1001; - } - } else if (fps_int =3D=3D 29.0) { - if (qAbs(fps - 29.97) < 0.01) { - profile.frame_rate_num =3D 30000; - profile.frame_rate_den =3D 1001; - } - } else if (fps_int =3D=3D 59.0) { - if (qAbs(fps - 59.94) < 0.01) { - profile.frame_rate_num =3D 60000; - profile.frame_rate_den =3D 1001; - } - } else { - // Unknown profile fps, warn user - adjustMessage =3D i18n("\nWarning: unknown non integer fps= , might cause incorrect duration display."); - } + adjustMessage =3D i18n("\nWarning: unknown non integer fps, mi= ght cause incorrect duration display."); } - if ((double)profile.frame_rate_num / profile.frame_rate_den !=3D f= ps) { + if (qAbs((double)profile.frame_rate_num / profile.frame_rate_den -= fps) > 0.01) { adjustMessage =3D i18n("\nProfile fps adjusted from original %= 1", QString::number(fps, 'f', 4)); } if (KMessageBox::warningContinueCancel(QApplication::activeWindow(= ), i18n("No profile found for your clip.\nCreate and switch to new profile = (%1x%2, %3fps)?%4", profile.width, profile.height, QString::number((double)= profile.frame_rate_num / profile.frame_rate_den, 'f', 2), adjustMessage)) = =3D=3D KMessageBox::Continue) {