View Single Post
Old 10-26-2016, 09:16 AM   #18
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,737
Karma: 206739468
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by KevinH View Post
Checking if first digit is a number is quite easy and if so prepending a non-number will work just fine.
Is checking even necessary? if a uuid is guaranteed to be unique, then prepending any non-number to the value Utility::CreateUUID()'s returns would guarantee both uniqueness and a spec compliant id value, no?

Unless a non-standard uuid would break something somewhere else in Sigil, I'm thinking that changing Utility::CreateUUID() to the following would suffice:

Code:
QString Utility::CreateUUID()
{
    return "s" + QUuid::createUuid().toString().remove("{").remove("}");
}
Or it could be done in OPFResource::GetUniqueID() if keeping Utility::CreateUUID() pure is necessary.

Code:
QString OPFResource::GetUniqueID(const QString &preferred_id, const OPFParser& p) const
{
    if (p.m_idpos.contains(preferred_id)) {
        return "s" + Utility::CreateUUID();
    }
    return preferred_id;
}

Last edited by DiapDealer; 10-26-2016 at 09:19 AM.
DiapDealer is offline   Reply With Quote