[gnome-software/wip/hughsie/unique-id-hash: 1/5] Do not allow plugins to set the kind to UNKNOWN if already set



commit 960f688563d03ec57566b365343654481ce46cd7
Author: Richard Hughes <richard hughsie com>
Date:   Thu Aug 25 15:50:37 2016 +0100

    Do not allow plugins to set the kind to UNKNOWN if already set

 src/gs-app.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 54855ee..5acbc43 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -896,6 +896,17 @@ gs_app_set_kind (GsApp *app, AsAppKind kind)
        if (app->kind == kind)
                return;
 
+       /* trying to change */
+       if (app->kind != AS_APP_KIND_UNKNOWN &&
+           kind == AS_APP_KIND_UNKNOWN) {
+               g_warning ("automatically prevented from changing "
+                          "kind on %s from %s to %s!",
+                          gs_app_get_unique_id (app),
+                          as_app_kind_to_string (app->kind),
+                          as_app_kind_to_string (kind));
+               return;
+       }
+
        /* check the state change is allowed */
        switch (app->kind) {
        case AS_APP_KIND_UNKNOWN:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]