mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 23:57:16 +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;
|
||||
|
||||
const auto actualCommandlineBuilder = qsl("%1 --")
|
||||
const auto neededCommandlineBuilder = qsl("%1 --")
|
||||
.arg((IsStaticBinary() || InAppImage())
|
||||
? cExeDir() + cExeName()
|
||||
: cExeName());
|
||||
|
||||
const auto actualCommandline = qsl("%1 %u")
|
||||
.arg(actualCommandlineBuilder);
|
||||
const auto neededCommandline = qsl("%1 %u")
|
||||
.arg(neededCommandlineBuilder);
|
||||
|
||||
auto currentAppInfo = g_app_info_get_default_for_type(
|
||||
kHandlerTypeName.utf8(),
|
||||
|
@ -1441,13 +1441,36 @@ void RegisterCustomScheme(bool force) {
|
|||
|
||||
g_object_unref(currentAppInfo);
|
||||
|
||||
if (currentCommandline == actualCommandline) {
|
||||
if (currentCommandline == neededCommandline) {
|
||||
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(
|
||||
actualCommandlineBuilder.toUtf8(),
|
||||
neededCommandlineBuilder.toUtf8(),
|
||||
AppName.utf8(),
|
||||
G_APP_INFO_CREATE_SUPPORTS_URIS,
|
||||
&error);
|
||||
|
|
Loading…
Add table
Reference in a new issue