mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Clean old attempts to register url scheme on scheme registration
This commit is contained in:
parent
6ccd53689d
commit
6f89598a7b
1 changed files with 28 additions and 5 deletions
|
@ -1423,13 +1423,13 @@ void RegisterCustomScheme(bool force) {
|
||||||
|
|
||||||
GError *error = nullptr;
|
GError *error = nullptr;
|
||||||
|
|
||||||
const auto actualCommandlineBuilder = qsl("%1 --")
|
const auto neededCommandlineBuilder = qsl("%1 --")
|
||||||
.arg((IsStaticBinary() || InAppImage())
|
.arg((IsStaticBinary() || InAppImage())
|
||||||
? cExeDir() + cExeName()
|
? cExeDir() + cExeName()
|
||||||
: cExeName());
|
: cExeName());
|
||||||
|
|
||||||
const auto actualCommandline = qsl("%1 %u")
|
const auto neededCommandline = qsl("%1 %u")
|
||||||
.arg(actualCommandlineBuilder);
|
.arg(neededCommandlineBuilder);
|
||||||
|
|
||||||
auto currentAppInfo = g_app_info_get_default_for_type(
|
auto currentAppInfo = g_app_info_get_default_for_type(
|
||||||
kHandlerTypeName.utf8(),
|
kHandlerTypeName.utf8(),
|
||||||
|
@ -1441,13 +1441,36 @@ void RegisterCustomScheme(bool force) {
|
||||||
|
|
||||||
g_object_unref(currentAppInfo);
|
g_object_unref(currentAppInfo);
|
||||||
|
|
||||||
if (currentCommandline == actualCommandline) {
|
if (currentCommandline == neededCommandline) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto registeredAppInfoList = g_app_info_get_recommended_for_type(
|
||||||
|
kHandlerTypeName.utf8());
|
||||||
|
|
||||||
|
for (auto l = registeredAppInfoList; l != nullptr; l = l->next) {
|
||||||
|
const auto currentRegisteredAppInfo = reinterpret_cast<GAppInfo*>(
|
||||||
|
l->data);
|
||||||
|
|
||||||
|
const auto currentAppInfoId = QString(
|
||||||
|
g_app_info_get_id(currentRegisteredAppInfo));
|
||||||
|
|
||||||
|
const auto currentCommandline = QString(
|
||||||
|
g_app_info_get_commandline(currentRegisteredAppInfo));
|
||||||
|
|
||||||
|
if (currentCommandline == neededCommandline
|
||||||
|
&& currentAppInfoId.startsWith(qsl("userapp-"))) {
|
||||||
|
g_app_info_delete(currentRegisteredAppInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (registeredAppInfoList) {
|
||||||
|
g_list_free_full(registeredAppInfoList, g_object_unref);
|
||||||
|
}
|
||||||
|
|
||||||
auto newAppInfo = g_app_info_create_from_commandline(
|
auto newAppInfo = g_app_info_create_from_commandline(
|
||||||
actualCommandlineBuilder.toUtf8(),
|
neededCommandlineBuilder.toUtf8(),
|
||||||
AppName.utf8(),
|
AppName.utf8(),
|
||||||
G_APP_INFO_CREATE_SUPPORTS_URIS,
|
G_APP_INFO_CREATE_SUPPORTS_URIS,
|
||||||
&error);
|
&error);
|
||||||
|
|
Loading…
Add table
Reference in a new issue