Conversation
| } | ||
|
|
||
| public async bool exec (out GLib.InputStream in_stream, out Soup.MessageHeaders response_headers) throws GLib.Error, Oopsie { | ||
| if (this.cancellable != null && !this.cancellable.is_cancelled ()) this.cancellable.cancel (); |
There was a problem hiding this comment.
| if (this.cancellable != null && !this.cancellable.is_cancelled ()) this.cancellable.cancel (); | |
| this.cancellable?.cancel (); |
GLib.Cancellable.cancel () already performs the already-cancelled check.
- async error parsing - remove useless cancelled branch - bool => void return type - handle cancelled properly
|
Thanks for the review! Maybe the API should change again and return the inputstream instead of outing it, now that we don't need to return bool |
|
Yeah that makes sense too. |
|
Moving forward with replacing all instances, something that caught my attention is vala's construction order: // Home.vala, moving the refreshing away from idle and to just the async function
construct {
url = "/api/v1/timelines/home";
label = _("Home");
icon = "tuba-user-home-symbolic";fails with url == null but public Home () {
Object (
url: "/api/v1/timelines/home",
label: _("Home")
);
}works. At the same, the Notifications.vala url depends on the account, which is not available during 🤔 Personally, I'd expect construct to run before using the Object at all. I know I'm wrong now, but I thought it was like this: construct -> Home () -> Object () |
|
More annoyances: public Views.ContentBase add_timeline_tab (string label, string icon, string url, Type accepts, string? empty_state_title = null, string? empty_state_icon = null) {
var tab = new Views.Accounts () {
url = url,
label = label,
icon = icon,
accepts = accepts
};url == null, but introducing this works: public class Tuba.Views.Accounts : Views.Timeline {
public Accounts.prefilled (string url, string label, string icon) {
Object (
url: url,
label: label,
icon: icon
);
} |
|
On top of GObject's already complicated construction/initialization flow, Vala adds its own layer of confusion 😭 I hate everything about the way it's done, and it's unlikely that I could change much here about Vala semantics (especially given the state of Vala maintenance, which makes it hard to get any non-trivial change merged into Vala). You would think Properties whose values are visible at
What you mean about From the GObject standpoint, the right thing to do is:
Here's a piece of code for you to play with: #! /usr/bin/vala
public class Base : Object {
public int some_prop {
set { print ("Setting some_prop to %d\n", value); }
}
public int some_construct_prop {
construct set { print ("Setting some_construct_prop to %d\n", value); }
}
public Base () {
print ("Base: before chain-up\n");
Object (some_prop: 42);
print ("Base: after chain-up\n");
}
construct {
print ("Base: construct block\n");
}
}
public class Derived : Base {
public Derived () {
print ("Derived: before chain-up\n");
base ();
print ("Derived: after chain-up\n");
}
construct {
print ("Derived: constrct block\n");
}
}
void main () {
new Derived ();
}I get: |
sup: #1481
fix: #1480