Check if registry key for file extension exists, before trying to actually read it. Avoids warning in the case when key doesn't exist.
This commit is contained in:
parent
6c59b4caf6
commit
df44d9b2d8
@ -203,21 +203,30 @@ void ShellIntegration::initializeTypes(const QString &lamexpFileType, const QStr
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasExistingType = false;
|
||||||
QString currentType;
|
QString currentType;
|
||||||
|
if(MUtils::Registry::reg_key_exists(MUtils::Registry::root_classes, currentExt))
|
||||||
|
{
|
||||||
if(MUtils::Registry::reg_value_read(MUtils::Registry::root_classes, currentExt, QString(), currentType))
|
if(MUtils::Registry::reg_value_read(MUtils::Registry::root_classes, currentExt, QString(), currentType))
|
||||||
{
|
{
|
||||||
currentType = QDir::toNativeSeparators(currentType);
|
currentType = QDir::toNativeSeparators(currentType);
|
||||||
if((currentType.compare(lamexpFileType, Qt::CaseInsensitive) != 0) && (!nativeTypes.contains(currentType, Qt::CaseInsensitive)))
|
if((currentType.compare(lamexpFileType, Qt::CaseInsensitive) != 0) && (!nativeTypes.contains(currentType, Qt::CaseInsensitive)))
|
||||||
{
|
{
|
||||||
nativeTypes.append(currentType);
|
nativeTypes.append(currentType);
|
||||||
|
hasExistingType = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
if(!hasExistingType)
|
||||||
{
|
{
|
||||||
|
currentType = lamexpFileType;
|
||||||
MUtils::Registry::reg_value_write(MUtils::Registry::root_user, QString("Software\\Classes\\%1").arg(currentExt), QString(), lamexpFileType);
|
MUtils::Registry::reg_value_write(MUtils::Registry::root_user, QString("Software\\Classes\\%1").arg(currentExt), QString(), lamexpFileType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(MUtils::Registry::reg_value_read(MUtils::Registry::root_user, QString("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%1\\UserChoice").arg(currentExt), progId, currentType))
|
const QString userChoiceKey = QString("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%1\\UserChoice").arg(currentExt);
|
||||||
|
if(MUtils::Registry::reg_key_exists(MUtils::Registry::root_user, userChoiceKey))
|
||||||
|
{
|
||||||
|
if(MUtils::Registry::reg_value_read(MUtils::Registry::root_user, userChoiceKey, progId, currentType))
|
||||||
{
|
{
|
||||||
currentType = QDir::toNativeSeparators(currentType);
|
currentType = QDir::toNativeSeparators(currentType);
|
||||||
if((currentType.compare(lamexpFileType, Qt::CaseInsensitive) != 0) && (!nativeTypes.contains(currentType, Qt::CaseInsensitive)))
|
if((currentType.compare(lamexpFileType, Qt::CaseInsensitive) != 0) && (!nativeTypes.contains(currentType, Qt::CaseInsensitive)))
|
||||||
@ -225,6 +234,7 @@ void ShellIntegration::initializeTypes(const QString &lamexpFileType, const QStr
|
|||||||
nativeTypes.append(currentType);
|
nativeTypes.append(currentType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QStringList progids;
|
QStringList progids;
|
||||||
if(MUtils::Registry::reg_enum_values(MUtils::Registry::root_user, QString("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%1\\OpenWithProgids").arg(currentExt), progids))
|
if(MUtils::Registry::reg_enum_values(MUtils::Registry::root_user, QString("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%1\\OpenWithProgids").arg(currentExt), progids))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user