[gnome-boxes/shut-build-warnings: 4/6] Fix various accesses to possible `null' variables
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/shut-build-warnings: 4/6] Fix various accesses to possible `null' variables
- Date: Wed, 6 May 2020 11:47:59 +0000 (UTC)
commit 5109e962fc3a65f69f1a0e8e5839790ba3620a5e
Author: Felipe Borges <felipeborges gnome org>
Date: Wed May 6 13:26:36 2020 +0200
Fix various accesses to possible `null' variables
src/actions-popover.vala | 11 ++++++++---
src/app-window.vala | 15 ++++++++++-----
src/app.vala | 12 ++++++++----
src/assistant/rhel-download-dialog.vala | 3 ++-
src/collection-filter-switcher.vala | 10 ++++++++--
src/collection.vala | 5 ++++-
src/display-toolbar.vala | 6 ++++--
src/downloads-hub.vala | 8 +++++---
src/i-properties-provider.vala | 11 +++++++++--
src/icon-view.vala | 18 ++++++++++++------
src/installer-media.vala | 9 ++++++---
src/libvirt-broker.vala | 9 +++++++--
src/list-view.vala | 22 +++++++++++++++-------
src/machine.vala | 10 ++++++----
src/media-manager.vala | 6 ++++--
src/os-database.vala | 3 ++-
src/properties-window.vala | 3 ++-
src/selectionbar.vala | 18 ++++++++++++------
src/snapshot-list-row.vala | 3 ++-
src/snapshots-property.vala | 7 +++++--
src/spice-display.vala | 8 +++++---
src/unattended-installer.vala | 21 ++++++++++++++-------
src/unattended-setup-box.vala | 5 ++++-
src/util-app.vala | 13 ++++++++-----
src/vm-creator.vala | 4 +++-
25 files changed, 165 insertions(+), 75 deletions(-)
---
diff --git a/src/actions-popover.vala b/src/actions-popover.vala
index f028bafa..9ba9b955 100644
--- a/src/actions-popover.vala
+++ b/src/actions-popover.vala
@@ -37,7 +37,8 @@ public void update_for_item (CollectionItem item) {
var menu = new GLib.Menu ();
var section = new GLib.Menu ();
- var importing = (machine is LibvirtMachine && (machine as LibvirtMachine).importing);
+ var libvirt_machine = machine as LibvirtMachine;
+ var importing = (machine is LibvirtMachine && libvirt_machine.importing);
// Open in new Window
if (window.ui_state != UIState.DISPLAY) {
@@ -149,7 +150,9 @@ private void force_shutdown_activated () {
}
private void restart_activated () {
- (window.current_item as Machine).restart ();
+ var machine = window.current_item as Machine;
+
+ machine.restart ();
}
private void delete_activated () {
@@ -162,7 +165,9 @@ private void delete_activated () {
}
private void clone_activated () {
- (window.current_item as Machine).clone.begin ();
+ var machine = window.current_item as Machine;
+
+ machine.clone.begin ();
}
private void send_file_activated () {
diff --git a/src/app-window.vala b/src/app-window.vala
index 6597a705..51cd94d3 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -256,8 +256,10 @@ private void ui_state_changed () {
case UIState.DISPLAY:
case UIState.WIZARD:
case UIState.PROPERTIES:
- if (current_item != null)
- (current_item as Machine).unschedule_autosave ();
+ if (current_item != null) {
+ var current_machine = current_item as Machine;
+ current_machine.unschedule_autosave ();
+ }
break;
@@ -335,7 +337,8 @@ public void show_send_file () {
uris_param.append (uri);
}
- (current_item as Machine).display.transfer_files (uris_param);
+ var machine = current_item as Machine;
+ machine.display.transfer_files (uris_param);
}
dialog.destroy ();
@@ -503,12 +506,14 @@ private bool on_delete_event () {
}
private void on_machine_state_notify () {
- if (this != App.app.main_window && (current_item as Machine).state != Machine.MachineState.RUNNING)
+ var current_machine = current_item as Machine;
+ if (this != App.app.main_window && current_machine.state != Machine.MachineState.RUNNING)
on_delete_event ();
}
private void on_machine_deleted_notify () {
- if (this != App.app.main_window && (current_item as Machine).deleted)
+ var current_machine = current_item as Machine;
+ if (this != App.app.main_window && current_machine.deleted)
on_delete_event ();
}
}
diff --git a/src/app.vala b/src/app.vala
index abbe9fbb..f8cba10b 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -11,7 +11,8 @@ public virtual async void add_source (CollectionSource source) throws GLib.Error
if (!(item is Machine))
continue;
- used_configs.append ((item as Machine).config);
+ var machine = item as Machine;
+ used_configs.append (machine.config);
}
source.purge_stale_box_configs (used_configs);
@@ -584,7 +585,8 @@ public void delete_machines_undoable (owned List<CollectionItem> items,
continue;
// Will also delete associated storage volume if by_user is 'true'
- (item as Machine).delete (true);
+ var machine = item as Machine;
+ machine.delete (true);
}
};
@@ -617,8 +619,10 @@ public new bool remove_window (AppWindow window) {
var initial_windows_count = windows.length ();
- if (window.current_item != null)
- (window.current_item as Machine).window = null;
+ if (window.current_item != null) {
+ var current_machine = window.current_item as Machine;
+ current_machine.window = null;
+ }
window.hide ();
diff --git a/src/assistant/rhel-download-dialog.vala b/src/assistant/rhel-download-dialog.vala
index ae41017a..8f9c6cd1 100644
--- a/src/assistant/rhel-download-dialog.vala
+++ b/src/assistant/rhel-download-dialog.vala
@@ -58,7 +58,8 @@ private bool on_decide_policy (WebKit.WebView web_view,
if (decision_type != WebKit.PolicyDecisionType.NAVIGATION_ACTION)
return false;
- var action = (decision as WebKit.NavigationPolicyDecision).get_navigation_action ();
+ var navigation_policy_decision = decision as WebKit.NavigationPolicyDecision;
+ var action = navigation_policy_decision.get_navigation_action ();
var request = action.get_request ();
var request_uri = request.get_uri ();
diff --git a/src/collection-filter-switcher.vala b/src/collection-filter-switcher.vala
index c6bb55f6..8aff0f4a 100644
--- a/src/collection-filter-switcher.vala
+++ b/src/collection-filter-switcher.vala
@@ -35,11 +35,17 @@ public void setup_ui (AppWindow window) {
}
private bool local_filter_func (Boxes.CollectionItem item) {
- return (item is Machine) && (item as Machine).is_local;
+ assert (item != null && item is Machine);
+ var machine = item as Machine;
+
+ return machine.is_local;
}
private bool remote_filter_func (Boxes.CollectionItem item) {
- return (item is Machine) && !(item as Machine).is_local;
+ assert (item != null && item is Machine);
+ var machine = item as Machine;
+
+ return !machine.is_local;
}
private void on_app_ready () {
diff --git a/src/collection.vala b/src/collection.vala
index 4fbbf510..2b073718 100644
--- a/src/collection.vala
+++ b/src/collection.vala
@@ -87,7 +87,10 @@ public void add_item (CollectionItem item) {
if (item1 == null || item2 == null)
return 0;
- return (item1 as CollectionItem).compare (item2 as CollectionItem);
+ var collection_item1 = item1 as CollectionItem;
+ var collection_item2 = item2 as CollectionItem;
+
+ return collection_item1.compare (collection_item2);
});
item_added (item);
diff --git a/src/display-toolbar.vala b/src/display-toolbar.vala
index b086743c..e506e65b 100644
--- a/src/display-toolbar.vala
+++ b/src/display-toolbar.vala
@@ -84,8 +84,10 @@ public void setup_ui (AppWindow window) {
back.visible = (window == App.app.main_window);
});
window.notify["ui-state"].connect (() => {
- if (window.ui_state == UIState.DISPLAY)
- (menu_button.popover as ActionsPopover).update_for_item (window.current_item);
+ if (window.ui_state == UIState.DISPLAY) {
+ var actions_popover = menu_button.popover as ActionsPopover;
+ actions_popover.update_for_item (window.current_item);
+ }
});
keys_menu_button.popover = new KeysInputPopover (window);
transfers_drawing_area.draw.connect (on_draw);
diff --git a/src/downloads-hub.vala b/src/downloads-hub.vala
index 3b1bc8ef..16f14c53 100644
--- a/src/downloads-hub.vala
+++ b/src/downloads-hub.vala
@@ -19,8 +19,9 @@ public static DownloadsHub get_instance () {
private double progress {
get {
double total = 0;
- foreach (var row in listbox.get_children ()) {
- total += (row as DownloadsHubRow).progress.progress / n_items;
+ foreach (var child in listbox.get_children ()) {
+ var row = child as DownloadsHubRow;
+ total += row.progress.progress / n_items;
}
return total;
@@ -40,7 +41,8 @@ public void add_item (WizardDownloadableEntry entry) {
if (!button.visible)
button.visible = true;
- var drawing_area = (button as Bin).get_child ();
+ var bin = button as Gtk.Bin;
+ var drawing_area = bin.get_child ();
drawing_area.draw.connect (draw_button_pie);
row.destroy.connect (on_row_deleted);
diff --git a/src/i-properties-provider.vala b/src/i-properties-provider.vala
index 3ed89e08..33b2b696 100644
--- a/src/i-properties-provider.vala
+++ b/src/i-properties-provider.vala
@@ -174,7 +174,10 @@ public SizeProperty (string name,
public int value {
get {
- return (widget as Gtk.SpinButton).get_value_as_int ();
+ var spin_button = widget as Gtk.SpinButton;
+ assert (spin_button != null);
+
+ return spin_button.get_value_as_int ();
}
}
@@ -196,7 +199,11 @@ public IntegerProperty (string name,
private class Boxes.StringProperty : Boxes.Property {
public string text {
- get { return (widget as Gtk.Label).label; }
+ get {
+ var label = widget as Gtk.Label;
+ assert (label != null);
+
+ return label.label; }
}
public StringProperty (string name, string value) {
diff --git a/src/icon-view.vala b/src/icon-view.vala
index b9dfe6ca..e3673eda 100644
--- a/src/icon-view.vala
+++ b/src/icon-view.vala
@@ -72,9 +72,11 @@ public void select_by_criteria (SelectionCriteria criteria) {
case SelectionCriteria.RUNNING:
foreach_child ((box_child) => {
var item = get_item_for_child (box_child);
- if (item != null && item is Machine && (item as Machine).is_running)
- select_child (box_child);
- else
+ if (item != null && item is Machine) {
+ var machine = item as Machine;
+ if (machine.is_running)
+ select_child (box_child);
+ } else
unselect_child (box_child);
});
@@ -173,8 +175,11 @@ private void on_child_activated (Gtk.FlowBoxChild child) {
}
var item = get_item_for_child (child);
- if (item is LibvirtMachine && (item as LibvirtMachine).importing)
- return;
+ if (item is LibvirtMachine) {
+ var machine = item as LibvirtMachine;
+ if (machine.importing)
+ return;
+ }
window.select_item (item);
@@ -208,7 +213,8 @@ private bool launch_context_popover_for_child (Gtk.FlowBoxChild child) {
if (item == null)
return false;
- var thumbnail = (child.get_child () as IconViewChild).thumbnail;
+ var icon_view_child = child.get_child () as IconViewChild;
+ var thumbnail = icon_view_child.thumbnail;
context_popover.update_for_item (item);
context_popover.set_relative_to (thumbnail);
diff --git a/src/installer-media.vala b/src/installer-media.vala
index ffae48ac..6be8e2f6 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -222,10 +222,13 @@ protected void label_setup (string? label = null) {
this.label = label;
else if (os != null && os_media != null) {
var variants = os_media.get_os_variants ();
- if (variants.get_length () > 0)
+ if (variants.get_length () > 0) {
// FIXME: Assuming first variant only from multivariant medias.
- this.label = (variants.get_nth (0) as OsVariant).get_name ();
- else
+ var variant = variants.get_nth (0) as OsVariant;
+ assert (variant != null);
+
+ this.label = variant.get_name ();
+ } else
this.label = os.get_name ();
} else {
// No appropriate label? :( Lets just use filename w/o extensions (if any) then
diff --git a/src/libvirt-broker.vala b/src/libvirt-broker.vala
index 2ea89cd8..8f73b7e0 100644
--- a/src/libvirt-broker.vala
+++ b/src/libvirt-broker.vala
@@ -33,7 +33,11 @@ public async LibvirtMachine add_domain (CollectionSource source, GVir.Connection
SourceFunc callback = add_domain.callback;
ulong id = 0;
id = App.app.collection.item_added.connect ((item) => {
- if (!(item is LibvirtMachine) || (item as LibvirtMachine).domain != domain)
+ if (!(item is LibvirtMachine))
+ return;
+
+ var libvirt_machine = item as LibvirtMachine;
+ if (libvirt_machine.domain != domain)
return;
App.app.collection.disconnect (id);
@@ -137,7 +141,8 @@ public override async void add_source (CollectionSource source) throws GLib.Erro
}
foreach (var clone in clones) {
- var disk_path = (clone.vm_creator as VMImporter).source_media.device_file;
+ var vm_importer = clone.vm_creator as VMImporter;
+ var disk_path = vm_importer.source_media.device_file;
LibvirtMachine? cloned = null;
for (int i = 0 ; i < App.app.collection.length ; i++) {
diff --git a/src/list-view.vala b/src/list-view.vala
index 3537c16d..82577e3c 100644
--- a/src/list-view.vala
+++ b/src/list-view.vala
@@ -111,9 +111,13 @@ public void select_by_criteria (SelectionCriteria criteria) {
case SelectionCriteria.RUNNING:
foreach_row ((box_row) => {
var item = get_item_for_row (box_row);
- if (item != null && item is Machine && (item as Machine).is_running)
- select_row (box_row);
- else
+ assert (item != null);
+
+ if (item != null && item is Machine) {
+ var machine = item as Machine;
+ if (machine.is_running)
+ select_row (box_row);
+ } else
unselect_row (box_row);
});
@@ -169,14 +173,18 @@ private void setup_list_box () {
return;
var item = get_item_for_row (box_row);
- if (item is LibvirtMachine && (item as LibvirtMachine).importing)
- return;
+ if (item is LibvirtMachine) {
+ var libvirt_machine = item as LibvirtMachine;
+ if (libvirt_machine.importing)
+ return;
+ }
window.select_item (item);
});
- (list_box as Gtk.Container).add.connect (add_row);
- (list_box as Gtk.Container).remove.connect (remove_row);
+ var container = list_box as Gtk.Container;
+ container.add.connect (add_row);
+ container.remove.connect (remove_row);
}
private CollectionItem? get_item_for_row (Gtk.ListBoxRow box_row) {
diff --git a/src/machine.vala b/src/machine.vala
index d3ed13f0..0e4ca0ec 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -644,7 +644,8 @@ private async void try_connect_display (ConnectFlags flags = ConnectFlags.NONE)
window.current_item = this;
window.show_properties ();
- var logs = (this as LibvirtMachine).properties.collect_logs ();
+ var libvirt_machine = this as LibvirtMachine;
+ var logs = libvirt_machine.properties.collect_logs ();
window.props_window.show_troubleshoot_log (logs);
};
@@ -770,9 +771,10 @@ private async void delete_auth_credentials () {
}
public override int compare (CollectionItem other) {
- if (other is Machine)
- return config.compare ((other as Machine).config);
- else
+ if (other is Machine) {
+ var machine = other as Machine;
+ return config.compare (machine.config);
+ } else
return -1; // Machines are listed before non-machines
}
diff --git a/src/media-manager.vala b/src/media-manager.vala
index b395046f..fee4b4c3 100644
--- a/src/media-manager.vala
+++ b/src/media-manager.vala
@@ -176,7 +176,8 @@ private static InstallerMedia create_unattended_installer (InstallerMedia media)
if (install_scripts.get_length () > 0) {
// Find out whether the media supports a script for DESKTOP profile
- install_scripts = (install_scripts as Osinfo.List).new_filtered (filter) as InstallScriptList;
+ var osinfo_list = install_scripts as Osinfo.List;
+ install_scripts = osinfo_list.new_filtered (filter) as InstallScriptList;
if (install_scripts.get_length () > 0) {
try {
@@ -192,7 +193,8 @@ private static InstallerMedia create_unattended_installer (InstallerMedia media)
// In case scripts are not set as part of the media, let's use the ones
// set as part of the OS.
install_scripts = media.os.get_install_script_list ();
- install_scripts = (install_scripts as Osinfo.List).new_filtered (filter) as InstallScriptList;
+ var osinfo_list = install_scripts as Osinfo.List;
+ install_scripts = osinfo_list.new_filtered (filter) as InstallScriptList;
if (install_scripts.get_length () > 0) {
try {
install_media = new UnattendedInstaller.from_media (media, install_scripts);
diff --git a/src/os-database.vala b/src/os-database.vala
index d8bf82fe..41fd8e70 100644
--- a/src/os-database.vala
+++ b/src/os-database.vala
@@ -128,7 +128,8 @@ public async Os get_os_by_id (string id) throws OSDatabaseError {
if (!(media.architecture in InstalledMedia.supported_architectures))
continue;
- var eol = (os as Product).get_eol_date ();
+ var product = os as Product;
+ var eol = product.get_eol_date ();
if (eol == null || now.compare (eol) < 1)
after_list.append (media);
}
diff --git a/src/properties-window.vala b/src/properties-window.vala
index 09adb2cf..f920a72e 100644
--- a/src/properties-window.vala
+++ b/src/properties-window.vala
@@ -83,7 +83,8 @@ public void copy_troubleshoot_log_to_clipboard () {
}
public void revert_state () {
- if ((app_window.current_item as Machine).state != Machine.MachineState.RUNNING &&
+ var current_machine = app_window.current_item as Machine;
+ if (current_machine.state != Machine.MachineState.RUNNING &&
app_window.previous_ui_state == UIState.DISPLAY)
app_window.set_state (UIState.COLLECTION);
else
diff --git a/src/selectionbar.vala b/src/selectionbar.vala
index de78a050..fb42fab9 100644
--- a/src/selectionbar.vala
+++ b/src/selectionbar.vala
@@ -134,9 +134,12 @@ private void update_delete_btn () {
});
item.set_data<ulong> ("can_delete_id", can_delete_id);
- if (item is Machine && !(item as Machine).can_delete) {
- sensitive = false;
- break;
+ if (item is Machine) {
+ var machine = item as Machine;
+ if (!machine.can_delete) {
+ sensitive = false;
+ break;
+ }
}
}
@@ -161,9 +164,12 @@ private void update_open_btn () {
});
item.set_data<ulong> ("importing_id", importing_id);
- if (item is LibvirtMachine && (item as LibvirtMachine).importing) {
- sensitive = false;
- break;
+ if (item is LibvirtMachine) {
+ var libvirt_machine = item as LibvirtMachine;
+ if (libvirt_machine.importing) {
+ sensitive = false;
+ break;
+ }
}
}
open_btn.sensitive = sensitive;
diff --git a/src/snapshot-list-row.vala b/src/snapshot-list-row.vala
index 1e16725d..5a758661 100644
--- a/src/snapshot-list-row.vala
+++ b/src/snapshot-list-row.vala
@@ -208,7 +208,8 @@ private void update_index () {
if (parent == null || !(parent is Gtk.ListBox))
return;
- var siblings = (parent as Gtk.Container).get_children ();
+ var container = parent as Gtk.Container;
+ var siblings = container.get_children ();
this.index = siblings.index (this);
this.parent_size = (int) siblings.length ();
}
diff --git a/src/snapshots-property.vala b/src/snapshots-property.vala
index 72781524..eaad25d5 100644
--- a/src/snapshots-property.vala
+++ b/src/snapshots-property.vala
@@ -104,8 +104,11 @@ private async void fetch_snapshots () {
private int config_sort_func (Gtk.ListBoxRow row1, Gtk.ListBoxRow row2) {
try {
- var conf1 = (row1 as SnapshotListRow).snapshot.get_config (0);
- var conf2 = (row2 as SnapshotListRow).snapshot.get_config (0);
+ var snapshot_row1 = row1 as SnapshotListRow;
+ var snapshot_row2 = row2 as SnapshotListRow;
+
+ var conf1 = snapshot_row1.snapshot.get_config (0);
+ var conf2 = snapshot_row2.snapshot.get_config (0);
if (conf1.get_creation_time () < conf2.get_creation_time ())
return -1;
else
diff --git a/src/spice-display.vala b/src/spice-display.vala
index 757287ed..b4c7ba00 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -192,7 +192,8 @@ public override void set_enable_audio (bool enable) {
/* FIXME: This is a temporary workaround for a mesa issue that causes
* Boxes to crash when calling spice_display_get_pixbuf ();
* See https://bugs.freedesktop.org/106811 */
- if ((machine as LibvirtMachine).acceleration_3d) {
+ var libvirt_machine = machine as LibvirtMachine;
+ if (libvirt_machine.acceleration_3d) {
return draw_pixbuf_client_side (display);
}
@@ -258,12 +259,13 @@ public override void connect_it (owned Display.OpenFDFunc? open_fd = null) {
}
public override void disconnect_it () {
+ var session_object = session as GLib.Object;
if (channel_new_id > 0) {
- (session as GLib.Object).disconnect (channel_new_id);
+ session_object.disconnect (channel_new_id);
channel_new_id = 0;
}
if (channel_destroy_id > 0) {
- (session as GLib.Object).disconnect (channel_destroy_id);
+ session_object.disconnect (channel_destroy_id);
channel_destroy_id = 0;
}
session.disconnect ();
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index c1dfd89c..2dabce71 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -17,7 +17,8 @@
var install_scripts = os_media.get_install_script_list ();
if (install_scripts.get_length () > 0) {
- install_scripts = (install_scripts as Osinfo.List).new_filtered (filter) as
InstallScriptList;
+ var osinfo_list = install_scripts as Osinfo.List;
+ install_scripts = osinfo_list.new_filtered (filter) as InstallScriptList;
if (install_scripts.get_length () > 0)
return true;
@@ -25,7 +26,8 @@
}
install_scripts = os.get_install_script_list ();
- install_scripts = (install_scripts as Osinfo.List).new_filtered (filter) as InstallScriptList;
+ var osinfo_list = install_scripts as Osinfo.List;
+ install_scripts = osinfo_list.new_filtered (filter) as InstallScriptList;
if (install_scripts.get_length () > 0)
return true;
@@ -43,9 +45,11 @@
owned get {
var devices = base.supported_devices;
- if (setup_box.express_install)
- return (devices as Osinfo.List).new_union (additional_devices) as Osinfo.DeviceList;
- else
+ if (setup_box.express_install) {
+ var osinfo_list = devices as Osinfo.List;
+
+ return osinfo_list.new_union (additional_devices) as Osinfo.DeviceList;
+ } else
return devices;
}
}
@@ -88,8 +92,11 @@
private InstallScriptInjectionMethod injection_method {
private get {
foreach (var unattended_file in unattended_files) {
- if (unattended_file is UnattendedScriptFile)
- return (unattended_file as UnattendedScriptFile).injection_method;
+ if (unattended_file is UnattendedScriptFile) {
+ var unattended_script_file = unattended_file as UnattendedScriptFile;
+
+ return unattended_script_file.injection_method;
+ }
}
return InstallScriptInjectionMethod.DISK;
diff --git a/src/unattended-setup-box.vala b/src/unattended-setup-box.vala
index 4a03bef8..330d5279 100644
--- a/src/unattended-setup-box.vala
+++ b/src/unattended-setup-box.vala
@@ -125,7 +125,10 @@ public UnattendedSetupBox (InstallerMedia media, string? product_key_format, boo
var msg = _("Express installation of %s requires an internet connection.").printf (media.label);
needs_internet_label.label = msg;
needs_internet_bar.visible = needs_internet;
- needs_password = (media as UnattendedInstaller).needs_password;
+
+ var unnatended_installer = media as UnattendedInstaller;
+ needs_password = unnatended_installer.needs_password;
+
media_path = media.device_file;
keyfile = new GLib.KeyFile ();
diff --git a/src/util-app.vala b/src/util-app.vala
index a41f28bd..ecef9460 100644
--- a/src/util-app.vala
+++ b/src/util-app.vala
@@ -87,7 +87,8 @@ public void use_list_box_separator (ListBoxRow row, ListBoxRow? before_row) {
var filter = new Osinfo.Filter ();
filter.add_constraint (prop_name, prop_value);
- var filtered = (devices as Osinfo.List).new_filtered (filter);
+ var osinfo_list = devices as Osinfo.List;
+ var filtered = osinfo_list.new_filtered (filter);
if (filtered.get_length () > 0)
return filtered.get_nth (0) as Osinfo.Device;
else
@@ -126,10 +127,12 @@ public string serialize_os_title (Osinfo.Media media) {
identifier. */
var variant = "";
var variants = media.get_os_variants ();
- if (variants.get_length () > 0)
- variant = (variants.get_nth (0) as Osinfo.OsVariant).get_name ();
- else if ((media.os as Osinfo.Product).name != null) {
- variant = (media.os as Osinfo.Product).name;
+ var product = media.os as Osinfo.Product;
+ if (variants.get_length () > 0) {
+ var os_variant = variants.get_nth (0) as Osinfo.OsVariant;
+ variant = os_variant.get_name ();
+ } else if (product.name != null) {
+ variant = product.name;
if (media.url != null && media.url.contains ("server"))
variant += " Server";
} else {
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index f3a6b461..c4b71aa5 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -11,8 +11,10 @@
public InstallerMedia? install_media { get; protected set; }
public bool express_install {
get {
+ var unattended_installer = install_media as UnattendedInstaller;
+
return ((install_media is UnattendedInstaller) &&
- (install_media as UnattendedInstaller).setup_box.express_install);
+ unattended_installer.setup_box.express_install);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]