Skip to content

VPR Graphics Crash Fixed #2045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 7 additions & 23 deletions vpr/src/draw/buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,21 @@ void button_for_net_alpha() {
gtk_grid_insert_column((GtkGrid*)grid, 0);

//text entry for apha value
GtkWidget* entry = gtk_entry_new();
std::string initialValue = std::to_string(get_net_alpha());
gtk_entry_set_text((GtkEntry*)entry, initialValue.c_str());
gtk_entry_set_input_purpose((GtkEntry*)entry, GTK_INPUT_PURPOSE_NUMBER);
gtk_widget_set_name(entry, "alphaValue");
gtk_entry_set_activates_default((GtkEntry*)entry, TRUE);
GtkWidget* alpha_widget = gtk_spin_button_new_with_range(0, 100, 1);
GtkWidget* alpha_label = gtk_label_new("Set Net Transparency:");
gtk_widget_set_name(alpha_widget, "netAlpha");

//label
GtkWidget* alpha_label = gtk_label_new("Set net transparency [0., 1.]");

//button
GtkWidget* button = gtk_button_new_with_label("set");

//attach to the grid
gtk_grid_attach((GtkGrid*)grid, entry, 0, 0, box_width, box_height);
gtk_grid_attach((GtkGrid*)grid, button, 1, 0, box_width, box_height);
gtk_grid_attach((GtkGrid*)main_window_grid, alpha_label, label_left_start_col, button_row++, box_width, box_height);
gtk_grid_attach((GtkGrid*)main_window_grid, grid, box_left_start_col, button_row++, box_width, box_height);
gtk_grid_attach((GtkGrid*)main_window_grid, alpha_widget, box_left_start_col, button_row++, box_width, box_height);

//show newly added contents
gtk_widget_show_all((GtkWidget*)main_window);

//connect signals
g_signal_connect_swapped(GTK_BUTTON(button),
"clicked",
g_signal_connect_swapped((GtkSpinButton*)alpha_widget,
"value_changed",
G_CALLBACK(set_net_alpha_value),
entry);
g_signal_connect_swapped(GTK_ENTRY(entry),
"activate",
G_CALLBACK(set_net_alpha_value_with_enter),
entry);
alpha_widget);
}

void button_for_toggle_nets() {
Expand Down
12 changes: 9 additions & 3 deletions vpr/src/draw/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4406,10 +4406,16 @@ static void highlight_blocks(double x, double y) {
application.update_message(msg);
application.refresh_drawing();
}
void set_net_alpha_value(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/) {
std::string fa(gtk_entry_get_text((GtkEntry*)widget));
void set_net_alpha_value(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/) {
std::string button_name = "netAlpha";
auto net_alpha = find_button(button_name.c_str());
t_draw_state* draw_state = get_draw_state_vars();
draw_state->net_alpha = std::stof(fa);

//set draw_state->net_alpha to its corresponding value in the ui
int new_value = gtk_spin_button_get_value_as_int((GtkSpinButton*)net_alpha) / 100;
draw_state->net_alpha = new_value;

//redraw
application.refresh_drawing();
}

Expand Down
4 changes: 3 additions & 1 deletion vpr/src/draw/draw_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,8 @@ bool valid_expression(std::string exp) {
}

//if expression started or ended with a bool operand or vector has and even number of operators (since in a valid expression number of operators are always odd)
if (ops[0] == BOOL_OP || ops[ops.size() - 1] == BOOL_OP || ops.size() % 2 == 0)
//checks if ops is empty first so trying to access ops[0] doesn't produce a seg fault
if (ops.size() == 0 || ops[0] == BOOL_OP || ops[ops.size() - 1] == BOOL_OP || ops.size() % 2 == 0)
return false;

//checks pattern (should be 0 1 0 1 0 ...) since in a valid expression comperator operators and bool operators are used in that pattern (e.g move_num == 3 || from_block == 11)
Expand All @@ -762,6 +763,7 @@ bool valid_expression(std::string exp) {
else if (j % 2 != 0 && ops[j] == COMP_OP)
return false;
}

return true;
}

Expand Down
Empty file removed vpr/src/power/power_utils.h
Empty file.