[Vala] Abuse of unowned?



The following code crashes when compiled with 0.11.6
due to an attempt to deallocate the static string "bar"
(https://bugzilla.gnome.org/show_bug.cgi?id=642350).

  struct Foo {
      public string foo;
      public string bar;
  }

  void main() {
     Foo f = Foo() {foo = "foo", bar = N_("bar")};
  }


As a work around, I change the struct strings to
unowned. Thus:

  struct Foo {
      public unowned string foo; 
      public unowned string bar;
  }


That seems to work. But I'm apprehensive here.
Is my workaround safe? Am I abusing "unowned"?


Nice day
Nor Jaidi Tuah




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