Skip to content

Commit

Permalink
Fixed midi property load core dump
Browse files Browse the repository at this point in the history
  • Loading branch information
g0orx committed Feb 16, 2021
1 parent 9292315 commit 77e132d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
2 changes: 2 additions & 0 deletions configure_dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "about_dialog.h"
#include "wideband_dialog.h"
#ifdef MIDI
#include "midi.h"
#include "midi_dialog.h"
#endif

Expand All @@ -60,6 +61,7 @@ static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
int i;

save_xvtr();
configure_midi_device(false);
radio->dialog=NULL;
for(i=0;i<radio->discovered->supported_receivers;i++) {
if(radio->receiver[i]!=NULL) {
Expand Down
24 changes: 12 additions & 12 deletions midi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,17 +419,16 @@ static int midi_action(void *data) {
receiver_move(rx,(long long)(rx->step*val),TRUE);
}
break;
/*
/////////////////////////////////////////////////////////// "CWL"
/////////////////////////////////////////////////////////// "CWR"
case CWL: // only key
case CWR: // only key
#ifdef LOCALCW
case CWLEFT: // only key
case CWRIGHT: // only key
//#ifdef LOCALCW
if (type == MIDI_KEY) {
new=(action == CWL);
keyer_event(new,val);
//keyer_event(new,val);
}
#endif
//#endif
break;
/////////////////////////////////////////////////////////// "CWSPEED"
case CWSPEED: // knob or wheel
Expand All @@ -440,22 +439,23 @@ static int midi_action(void *data) {
break;
case MIDI_WHEEL:
// here we allow from 1 to 60 wpm
new = cw_keyer_speed + val;
new = radio->cw_keyer_speed + val;
if (new < 1) new=1;
if (new > 60) new=60;
break;
default:
// do not change
// we should not come here anyway
new = cw_keyer_speed;
new = radio->cw_keyer_speed;
break;
}
cw_keyer_speed=new;
#ifdef LOCALCW
keyer_update();
#endif
radio->cw_keyer_speed=new;
//#ifdef LOCALCW
//keyer_update();
//#endif
g_idle_add(ext_vfo_update, NULL);
break;
/*
/////////////////////////////////////////////////////////// "DIVCOARSEGAIN"
case DIV_COARSEGAIN: // knob or wheel supported
case DIV_FINEGAIN: // knob or wheel supported
Expand Down
18 changes: 9 additions & 9 deletions midi_dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static void device_changed_cb(GtkWidget *widget, gpointer data) {

static void type_changed_cb(GtkWidget *widget, gpointer data) {
int i=1;
int j;
int j=1;

// update actions available for the type
gchar *type=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widget));
Expand All @@ -149,9 +149,8 @@ static void type_changed_cb(GtkWidget *widget, gpointer data) {
gtk_combo_box_set_active (GTK_COMBO_BOX(newAction),0);
} else if(strcmp(type,"KEY")==0) {
// add all the Key actions
j=0;
while(ActionTable[i].action!=ACTION_NONE) {
if(ActionTable[i].type==MIDI_KEY) {
if(ActionTable[i].type&MIDI_KEY) {
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newAction),NULL,ActionTable[i].str);
if(ActionTable[i].action==thisAction) {
gtk_combo_box_set_active (GTK_COMBO_BOX(newAction),j);
Expand All @@ -162,7 +161,6 @@ static void type_changed_cb(GtkWidget *widget, gpointer data) {
}
} else if(strcmp(type,"KNOB/SLIDER")==0) {
// add all the Knob actions
j=0;
while(ActionTable[i].action!=ACTION_NONE) {
if(ActionTable[i].type&MIDI_KNOB) {
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newAction),NULL,ActionTable[i].str);
Expand All @@ -175,7 +173,6 @@ static void type_changed_cb(GtkWidget *widget, gpointer data) {
}
} else if(strcmp(type,"WHEEL")==0) {
// add all the Wheel actions
j=0;
while(ActionTable[i].action!=ACTION_NONE) {
if(ActionTable[i].type&MIDI_WHEEL || ActionTable[i].type&MIDI_KNOB) {
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newAction),NULL,ActionTable[i].str);
Expand Down Expand Up @@ -239,7 +236,7 @@ static void tree_selection_changed_cb (GtkTreeSelection *selection, gpointer dat
thisType=TYPE_NONE;
}
thisAction=ACTION_NONE;
int i=0;
int i=1;
while(ActionTable[i].action!=ACTION_NONE) {
if(strcmp(ActionTable[i].str,str_action)==0) {
thisAction=ActionTable[i].action;
Expand Down Expand Up @@ -601,15 +598,15 @@ static void update_cb(GtkButton *widget,gpointer user_data) {
static void delete_cb(GtkButton *widget,gpointer user_data) {
struct desc *previous_cmd;
struct desc *next_cmd;
GtkTreeIter saved_iter;

//g_print("%s\n",__FUNCTION__);
saved_iter=iter;

// remove from list store
gtk_list_store_remove(store,&iter);

// remove from MidiCommandsTable
if(MidiCommandsTable.desc[thisNote]==current_cmd) {
MidiCommandsTable.desc[thisNote]=current_cmd->next;
MidiCommandsTable.desc[thisNote]=NULL;
g_free(current_cmd);
} else {
previous_cmd=MidiCommandsTable.desc[thisNote];
Expand All @@ -624,6 +621,9 @@ static void delete_cb(GtkButton *widget,gpointer user_data) {
}
}

// remove from list store
gtk_list_store_remove(store,&saved_iter);

gtk_widget_set_sensitive(add_b,true);
gtk_widget_set_sensitive(update_b,false);
gtk_widget_set_sensitive(delete_b,false);
Expand Down

0 comments on commit 77e132d

Please sign in to comment.