File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,9 @@ public class Installer.DiskBar: Gtk.Box {
116116 );
117117 }
118118
119+ // make sure if somehow used_sectors > total_disk_sectors, we clamp it to total_disk_sectors
120+ used_sectors = uint64 . min (used_sectors, total_disk_sectors);
121+
119122 // If more than 1% of the disk is unused, show a block for the unused space
120123 var unused_sectors = total_disk_sectors - used_sectors;
121124 if ((double ) unused_sectors / total_disk_sectors > 0.01 ) {
@@ -147,8 +150,11 @@ public class Installer.DiskBar: Gtk.Box {
147150 }
148151
149152 private void append_partition (Gtk .Widget widget , double percentage ) {
150- // Truncate to 2 decimal places (round down), to ensure we don't go over 100% because of rounding errors
151- percentage = (int )(percentage * 100 ) / 100.0 ;
153+ // Truncate to 2 decimal places (round down), to ensure we don't go over 100% because of rounding errors.
154+ // Also make sure percentage is never 0, otherwise we can assertion error:
155+ // gtk_constraint_expression_new_subject: assertion failed: (!G_APPROX_VALUE (term->coefficient, 0.0, 0.001))
156+ // Also we assume partitions.size is less than 100
157+ percentage = ((int ) (percentage * 100 ) / 100.0 ). clamp (0.01 , 1.0 - partitions. size / 100.0 );
152158
153159 widget. set_parent (this );
154160
You can’t perform that action at this time.
0 commit comments