Skip to content

Commit

Permalink
Fix recursive constructor invocation (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
meisenzahl committed Oct 20, 2020
1 parent 14d2892 commit 2744ee1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Permissions/Backend/App.vala
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public class Permissions.Backend.App : GLib.Object {
private string get_overrides_path () {
var overrides_folder_path = GLib.Path.build_path (
GLib.Path.DIR_SEPARATOR_S,
AppManager.get_default ().user_installation_path,
FlatpakManager.get_default ().user_installation_path,
"overrides"
);

Expand Down
2 changes: 0 additions & 2 deletions src/Permissions/Backend/AppManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

public class Permissions.Backend.AppManager : GLib.Object {
public HashTable<string, Backend.App> apps { get; private set; }
public string user_installation_path { get; private set; }

private static AppManager? instance;
public static AppManager get_default () {
Expand All @@ -37,7 +36,6 @@ public class Permissions.Backend.AppManager : GLib.Object {

try {
var installation = new Flatpak.Installation.user ();
user_installation_path = installation.get_path ().get_path ();
get_apps_for_installation (installation);
} catch (Error e) {
critical ("Unable to get flatpak user installation : %s", e.message);
Expand Down
42 changes: 42 additions & 0 deletions src/Permissions/Backend/FlatpakManager.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2020 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Marius Meisenzahl <[email protected]>
*/

public class Permissions.Backend.FlatpakManager : GLib.Object {
public string user_installation_path { get; private set; }

private static FlatpakManager? instance;
public static FlatpakManager get_default () {
if (instance == null) {
instance = new FlatpakManager ();
}

return instance;
}

construct {
try {
var installation = new Flatpak.Installation.user ();
user_installation_path = installation.get_path ().get_path ();
} catch (Error e) {
critical ("Unable to get flatpak user installation : %s", e.message);
}
}
}
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ plug_files = files(
'Defaults/DefaultPlug.vala',
'Permissions/Backend/App.vala',
'Permissions/Backend/AppManager.vala',
'Permissions/Backend/FlatpakManager.vala',
'Permissions/Backend/PermissionSettings.vala',
'Permissions/Widgets/AppSettingsView.vala',
'Permissions/Widgets/PermissionSettingsWidget.vala',
Expand Down

0 comments on commit 2744ee1

Please sign in to comment.