diff options
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/src/audiohandler.c | 10 | ||||
-rw-r--r-- | gtk/src/callbacks.c | 198 | ||||
-rw-r--r-- | gtk/src/ghb-dvd.c | 4 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 89 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 13 | ||||
-rw-r--r-- | gtk/src/main.c | 20 | ||||
-rw-r--r-- | gtk/src/presets.c | 25 | ||||
-rw-r--r-- | gtk/src/preview.c | 4 | ||||
-rw-r--r-- | gtk/src/queuehandler.c | 12 | ||||
-rw-r--r-- | gtk/src/subtitlehandler.c | 9 | ||||
-rw-r--r-- | gtk/src/values.c | 4 | ||||
-rw-r--r-- | gtk/src/x264handler.c | 2 |
12 files changed, 237 insertions, 153 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c index 6c00e3c72..d5ae66f3f 100644 --- a/gtk/src/audiohandler.c +++ b/gtk/src/audiohandler.c @@ -284,6 +284,7 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) gval = ghb_widget_value(widget); acodec = ghb_lookup_combo_int("AudioEncoder", gval); ghb_value_free(gval); + widget = GHB_WIDGET(ud->builder, "AudioMixdown"); gval = ghb_widget_value(widget); mix = ghb_lookup_combo_int("AudioMixdown", gval); @@ -292,11 +293,12 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) widget = GHB_WIDGET(ud->builder, "AudioBitrate"); gval = ghb_widget_value(widget); bitrate = ghb_lookup_combo_int("AudioBitrate", gval); + ghb_value_free(gval); widget = GHB_WIDGET(ud->builder, "AudioSamplerate"); gval = ghb_widget_value(widget); sr = ghb_lookup_combo_int("AudioSamplerate", gval); - + ghb_value_free(gval); aconfig = ghb_get_scan_audio_info(titleindex, track); if (sr == 0) @@ -2031,7 +2033,9 @@ audio_remove_lang_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) // Remove from preset language list alang_list = ghb_settings_get_value(ud->settings, "AudioLanguageList"); + GValue *glang = ghb_array_get_nth(alang_list, index); ghb_array_remove(alang_list, index); + ghb_value_free(glang); ghb_clear_presets_selection(ud); } } @@ -2263,7 +2267,9 @@ audio_def_setting_remove_cb(GtkWidget *widget, signal_user_data_t *ud) return; } gtk_widget_destroy(GTK_WIDGET(row)); + GValue *asettings = ghb_array_get_nth(alist, index); ghb_array_remove(alist, index); + ghb_value_free(asettings); ghb_clear_presets_selection(ud); } @@ -2369,7 +2375,9 @@ audio_def_lang_list_init(signal_user_data_t *ud) { // Error in list. Probably duplicate languages. Remove // this item from the list. + GValue *glang = ghb_array_get_nth(lang_list, ii); ghb_array_remove(lang_list, ii); + ghb_value_free(glang); count--; } } diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 597faec33..d22254339 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -134,7 +134,10 @@ dep_check(signal_user_data_t *ud, const gchar *name, gboolean *out_hide) widget = GHB_WIDGET(ud->builder, widget_name); dep_object = gtk_builder_get_object(ud->builder, name); if (widget != NULL && !gtk_widget_is_sensitive(widget)) + { + g_free(widget_name); continue; + } if (dep_object == NULL) { g_message("Failed to find widget"); @@ -929,12 +932,62 @@ static void show_container_options(signal_user_data_t *ud) gtk_widget_set_visible(w3, (mux & HB_MUX_MASK_MP4) && (enc == HB_VCODEC_X264)); } +static void +adjustment_configure( + GtkAdjustment *adj, + double val, + double min, double max, + double step, double page, double page_sz) +{ + gtk_adjustment_configure(adj, val, min, max, step, page, page_sz); +} + +static void +spin_configure(signal_user_data_t *ud, char *name, double val, double min, double max) +{ + GtkSpinButton *spin; + GtkAdjustment *adj; + double step, page, page_sz; + + spin = GTK_SPIN_BUTTON(GHB_WIDGET(ud->builder, name)); + + adj = gtk_spin_button_get_adjustment(spin); + step = gtk_adjustment_get_step_increment(adj); + page = gtk_adjustment_get_page_increment(adj); + page_sz = gtk_adjustment_get_page_size(adj); + + adjustment_configure(adj, val, min, max, step, page, page_sz); +} + +static void +scale_configure( + signal_user_data_t *ud, + char *name, + double val, double min, double max, + double step, double page, + int digits, gboolean inverted) +{ + GtkScale *scale; + GtkAdjustment *adj; + double page_sz; + + scale = GTK_SCALE(GHB_WIDGET(ud->builder, name)); + + adj = gtk_range_get_adjustment(GTK_RANGE(scale)); + page_sz = gtk_adjustment_get_page_size(adj); + + adjustment_configure(adj, val, min, max, step, page, page_sz); + + gtk_scale_set_digits(scale, digits); + gtk_range_set_inverted(GTK_RANGE(scale), inverted); +} + void ghb_set_widget_ranges(signal_user_data_t *ud, GValue *settings) { - GtkWidget *widget; int titleindex = ghb_settings_combo_int(settings, "title"); hb_title_t * title = ghb_get_title_info(titleindex); + double val; // Reconfigure the UI combo boxes ghb_update_ui_combo_box(ud, "AudioTrack", titleindex, FALSE); @@ -942,61 +995,62 @@ ghb_set_widget_ranges(signal_user_data_t *ud, GValue *settings) if (title != NULL) { + // Set the limits of cropping. hb_set_anamorphic_size crashes if // you pass it a cropped width or height == 0. - gint bound; - bound = title->height / 2 - 8; - widget = GHB_WIDGET(ud->builder, "PictureTopCrop"); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 0, bound); - widget = GHB_WIDGET(ud->builder, "PictureBottomCrop"); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 0, bound); - bound = title->width / 2 - 8; - widget = GHB_WIDGET(ud->builder, "PictureLeftCrop"); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 0, bound); - widget = GHB_WIDGET(ud->builder, "PictureRightCrop"); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 0, bound); + gint vbound, hbound; + vbound = title->height / 2 - 8; + hbound = title->width / 2 - 8; + + val = ghb_settings_get_int(ud->settings, "PictureTopCrop"); + spin_configure(ud, "PictureTopCrop", val, 0, vbound); + val = ghb_settings_get_int(ud->settings, "PictureBottomCrop"); + spin_configure(ud, "PictureBottomCrop", val, 0, vbound); + val = ghb_settings_get_int(ud->settings, "PictureLeftCrop"); + spin_configure(ud, "PictureLeftCrop", val, 0, hbound); + val = ghb_settings_get_int(ud->settings, "PictureRightCrop"); + spin_configure(ud, "PictureRightCrop", val, 0, hbound); gint duration = title->duration / 90000; - gint num_chapters = hb_list_count(title->list_chapter); if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0) { - widget = GHB_WIDGET(ud->builder, "start_point"); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 1, num_chapters); - widget = GHB_WIDGET(ud->builder, "end_point"); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 1, num_chapters); + gint num_chapters = hb_list_count(title->list_chapter); + + val = ghb_settings_get_int(ud->settings, "start_point"); + spin_configure(ud, "start_point", val, 1, num_chapters); + val = ghb_settings_get_int(ud->settings, "end_point"); + spin_configure(ud, "end_point", val, 1, num_chapters); } else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 1) { - - widget = GHB_WIDGET (ud->builder, "start_point"); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 0, duration-1); - widget = GHB_WIDGET (ud->builder, "end_point"); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 1, duration); + val = ghb_settings_get_int(ud->settings, "start_point"); + spin_configure(ud, "start_point", val, 0, duration-1); + val = ghb_settings_get_int(ud->settings, "end_point"); + spin_configure(ud, "end_point", val, 0, duration); } else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 2) { - gdouble max_frames = (gdouble)duration * title->rate / title->rate_base; - widget = GHB_WIDGET(ud->builder, "start_point"); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 1, max_frames); - widget = GHB_WIDGET(ud->builder, "end_point"); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 1, max_frames); + gdouble max_frames; + max_frames = (gdouble)duration * title->rate / title->rate_base; + + val = ghb_settings_get_int(ud->settings, "start_point"); + spin_configure(ud, "start_point", val, 1, max_frames); + val = ghb_settings_get_int(ud->settings, "end_point"); + spin_configure(ud, "end_point", val, 1, max_frames); } - widget = GHB_WIDGET (ud->builder, "angle"); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 1, title->angle_count); + val = ghb_settings_get_int(ud->settings, "angle"); + spin_configure(ud, "angle", val, 1, title->angle_count); } - gdouble vqmin, vqmax, step, page; - gboolean inverted; - gint digits; + float vqmin, vqmax, step, page; + int inverted, digits; ghb_vquality_range(ud, &vqmin, &vqmax, &step, &page, &digits, &inverted); - GtkWidget *qp = GHB_WIDGET(ud->builder, "VideoQualitySlider"); - gtk_range_set_range (GTK_RANGE(qp), vqmin, vqmax); - gtk_range_set_increments (GTK_RANGE(qp), step, page); - gtk_scale_set_digits(GTK_SCALE(qp), digits); - gtk_range_set_inverted (GTK_RANGE(qp), inverted); + val = ghb_settings_get_double(ud->settings, "VideoQualitySlider"); + scale_configure(ud, "VideoQualitySlider", val, vqmin, vqmax, + step, page, digits, inverted); } static void @@ -1059,14 +1113,14 @@ ghb_load_settings(signal_user_data_t * ud) ghb_settings_set_boolean(ud->settings, "preset_reload", FALSE); } + ud->dont_clear_presets = TRUE; + ud->scale_busy = TRUE; + ghb_set_widget_ranges(ud, ud->settings); ghb_check_all_depencencies(ud); show_container_options(ud); check_chapter_markers(ud); - ud->dont_clear_presets = TRUE; - ud->scale_busy = TRUE; - ghb_settings_to_ui(ud, ud->settings); ghb_audio_defaults_to_ui(ud); ghb_subtitle_defaults_to_ui(ud); @@ -1797,12 +1851,12 @@ load_all_titles(signal_user_data_t *ud, int titleindex) GValue *settings = ghb_settings_new(); ghb_settings_init(settings, "Initialization"); - ghb_settings_init(settings, "Presets"); ghb_preset_to_settings(settings, preset); ghb_settings_set_value(settings, "preset", preset_path); set_title_settings(ud, settings, ii); ghb_array_append(settings_array, settings); } + ghb_value_free(preset_path); if (titleindex < 0 || titleindex >= count) { titleindex = 0; @@ -1874,38 +1928,23 @@ ptop_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud) if (title == NULL) return; - gint num_chapters = hb_list_count(title->list_chapter); gint duration = title->duration / 90000; if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0) { - widget = GHB_WIDGET (ud->builder, "start_point"); - gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, num_chapters); - gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1); - - widget = GHB_WIDGET (ud->builder, "end_point"); - gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, num_chapters); - gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), num_chapters); + gint num_chapters = hb_list_count(title->list_chapter); + spin_configure(ud, "start_point", 1, 1, num_chapters); + spin_configure(ud, "end_point", num_chapters, 1, num_chapters); } else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 1) { - widget = GHB_WIDGET (ud->builder, "start_point"); - gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 0, duration-1); - gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 0); - - widget = GHB_WIDGET (ud->builder, "end_point"); - gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, duration); - gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), duration); + spin_configure(ud, "start_point", 0, 0, duration-1); + spin_configure(ud, "end_point", duration, 0, duration); } else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 2) { gdouble max_frames = (gdouble)duration * title->rate / title->rate_base; - widget = GHB_WIDGET (ud->builder, "start_point"); - gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, max_frames); - gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1); - - widget = GHB_WIDGET (ud->builder, "end_point"); - gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, max_frames); - gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), max_frames); + spin_configure(ud, "start_point", 1, 1, max_frames); + spin_configure(ud, "end_point", max_frames, 1, max_frames); } } @@ -2006,30 +2045,26 @@ http_opt_changed_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void vcodec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { - gdouble vqmin, vqmax, step, page; - gboolean inverted; - gint digits; + float val, vqmin, vqmax, step, page; + int inverted, digits; ghb_widget_to_setting(ud->settings, widget); ghb_check_dependency(ud, widget, NULL); show_container_options(ud); ghb_clear_presets_selection(ud); ghb_live_reset(ud); + + val = ghb_vquality_default(ud); ghb_vquality_range(ud, &vqmin, &vqmax, &step, &page, &digits, &inverted); - GtkWidget *qp = GHB_WIDGET(ud->builder, "VideoQualitySlider"); - gtk_range_set_range (GTK_RANGE(qp), vqmin, vqmax); - gtk_range_set_increments (GTK_RANGE(qp), step, page); - gtk_scale_set_digits(GTK_SCALE(qp), digits); - gtk_range_set_inverted (GTK_RANGE(qp), inverted); + scale_configure(ud, "VideoQualitySlider", val, vqmin, vqmax, + step, page, digits, inverted); } G_MODULE_EXPORT void start_point_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { gint start, end; - const gchar *name = ghb_get_setting_key(widget); - g_debug("start_point_changed_cb () %s", name); ghb_widget_to_setting(ud->settings, widget); if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0) { @@ -2072,9 +2107,7 @@ G_MODULE_EXPORT void end_point_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { gint start, end; - const gchar *name = ghb_get_setting_key(widget); - g_debug("end_point_changed_cb () %s", name); ghb_widget_to_setting(ud->settings, widget); if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0) { @@ -2953,6 +2986,7 @@ ghb_backend_events(signal_user_data_t *ud) source = ghb_settings_get_string(ud->globals, "scan_source"); update_source_label(ud, source); + g_free(source); scan_prog = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "scan_prog")); gtk_progress_bar_set_fraction (scan_prog, 1.0); @@ -3683,7 +3717,7 @@ update_chapter_list_settings(GValue *settings) titleindex = ghb_settings_get_int(settings, "title_no"); chapters = ghb_get_chapters(titleindex); if (chapters) - ghb_settings_set_value(settings, "chapter_list", chapters); + ghb_settings_take_value(settings, "chapter_list", chapters); } static gint chapter_edit_key = 0; @@ -3909,14 +3943,13 @@ vqual_granularity_changed_cb(GtkWidget *widget, signal_user_data_t *ud) const gchar *name = ghb_get_setting_key(widget); ghb_pref_set(ud->prefs, name); - gdouble vqmin, vqmax, step, page; - gboolean inverted; - gint digits; + float val, vqmin, vqmax, step, page; + int inverted, digits; ghb_vquality_range(ud, &vqmin, &vqmax, &step, &page, &digits, &inverted); - GtkWidget *qp = GHB_WIDGET(ud->builder, "VideoQualitySlider"); - gtk_range_set_increments (GTK_RANGE(qp), step, page); - gtk_scale_set_digits(GTK_SCALE(qp), digits); + val = ghb_settings_get_double(ud->settings, "VideoQualitySlider"); + scale_configure(ud, "VideoQualitySlider", val, vqmin, vqmax, + step, page, digits, inverted); } G_MODULE_EXPORT void @@ -4092,6 +4125,7 @@ ghb_is_cd(GDrive *gd) gint val; val = g_udev_device_get_property_as_int(udd, "ID_CDROM_DVD"); + g_object_unref(udd); if (val == 1) return TRUE; diff --git a/gtk/src/ghb-dvd.c b/gtk/src/ghb-dvd.c index bcd7e1311..133580d5a 100644 --- a/gtk/src/ghb-dvd.c +++ b/gtk/src/ghb-dvd.c @@ -389,6 +389,10 @@ ghb_dvd_set_current(const gchar *name, signal_user_data_t *ud) // think its neccessary. ud->current_dvd_device = resolved; } + else + { + g_free(resolved); + } g_object_unref(info); } else diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 5dff6898d..ae09f6dc4 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -696,59 +696,62 @@ ghb_version() return hb_get_version(NULL); } +float +ghb_vquality_default(signal_user_data_t *ud) +{ + float quality; + gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder"); + + switch (vcodec) + { + case HB_VCODEC_X264: + return 20; + case HB_VCODEC_THEORA: + return 45; + case HB_VCODEC_FFMPEG_MPEG2: + case HB_VCODEC_FFMPEG_MPEG4: + return 3; + default: + { + float min, max, step; + int direction; + + hb_video_quality_get_limits(vcodec, &min, &max, &step, &direction); + // Pick something that is 70% of max + // Probably too low for some and too high for others... + quality = (max - min) * 0.7; + if (direction) + quality = max - quality; + } + } + return quality; +} + void ghb_vquality_range( signal_user_data_t *ud, - gdouble *min, - gdouble *max, - gdouble *step, - gdouble *page, + float *min, + float *max, + float *step, + float *page, gint *digits, - gboolean *inverted) + int *direction) { + float min_step; gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder"); + *page = 10; *digits = 0; - switch (vcodec) - { - case HB_VCODEC_X264: - { - *min = 0; - *max = 51; - *step = ghb_settings_combo_double(ud->prefs, - "VideoQualityGranularity"); - if (*step == 0.2 || *step == 0.5) - *digits = 1; - else if (*step == 0.25) - *digits = 2; - *inverted = TRUE; - } break; - - case HB_VCODEC_FFMPEG_MPEG2: - case HB_VCODEC_FFMPEG_MPEG4: - { - *min = 1; - *max = 31; - *step = 1; - *inverted = TRUE; - } break; + hb_video_quality_get_limits(vcodec, min, max, &min_step, direction); + *step = ghb_settings_combo_double(ud->prefs, "VideoQualityGranularity"); - case HB_VCODEC_THEORA: - { - *min = 0; - *max = 63; - *step = 1; - *inverted = FALSE; - } break; + if (*step < min_step) + *step = min_step; - default: - { - *min = 0; - *max = 100; - *step = 1; - *inverted = FALSE; - } break; - } + if ((int)(*step * 100) % 10 != 0) + *digits = 2; + else if ((int)(*step * 10) % 10 != 0) + *digits = 1; } gint diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index 3caae6225..8311de9a2 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -72,13 +72,14 @@ typedef struct const gchar* ghb_version(void); void ghb_vquality_range( signal_user_data_t *ud, - gdouble *min, - gdouble *max, - gdouble *step, - gdouble *page, + float *min, + float *max, + float *step, + float *page, gint *digits, - gboolean *inverted); -//const gchar* ghb_get_rate_string(gint rate, gint type); + int *direction); +float ghb_vquality_default(signal_user_data_t *ud); + void ghb_combo_init(signal_user_data_t *ud); void ghb_backend_init(gint debug); void ghb_backend_close(void); diff --git a/gtk/src/main.c b/gtk/src/main.c index 5b2a3b43b..9232a1fc6 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -286,6 +286,8 @@ bind_queue_tree_model(signal_user_data_t *ud) gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column)); gtk_tree_view_column_set_expand(column, TRUE); gtk_tree_view_column_set_max_width(column, 550); + g_signal_connect(treeview, "size-allocate", queue_list_size_allocate_cb, + textcell); cell = custom_cell_renderer_button_new(); column = gtk_tree_view_column_new_with_attributes( @@ -300,8 +302,6 @@ bind_queue_tree_model(signal_user_data_t *ud) g_signal_connect(selection, "changed", queue_list_selection_changed_cb, ud); g_signal_connect(cell, "clicked", queue_remove_clicked_cb, ud); - g_signal_connect(treeview, "size-allocate", queue_list_size_allocate_cb, - textcell); g_signal_connect(treeview, "drag_data_received", queue_drag_cb, ud); g_signal_connect(treeview, "drag_motion", queue_drag_motion_cb, ud); } @@ -868,8 +868,6 @@ main(int argc, char *argv[]) gtk_rc_parse_string(hud_rcstyle); #endif - g_type_class_unref(g_type_class_ref(GTK_TYPE_BUTTON)); - g_object_set(gtk_settings_get_default(), "gtk-button-images", TRUE, NULL); #if !defined(_WIN32) notify_init("HandBrake"); #endif @@ -1273,15 +1271,23 @@ main(int argc, char *argv[]) gtk_main(); gtk_status_icon_set_visible(si, FALSE); ghb_backend_close(); - if (ud->queue) - ghb_value_free(ud->queue); - ghb_value_free(ud->settings); + + ghb_value_free(ud->queue); + ghb_value_free(ud->settings_array); + ghb_value_free(ud->prefs); + ghb_value_free(ud->globals); + ghb_value_free(ud->x264_priv); + g_io_channel_unref(ud->activity_log); ghb_settings_close(); ghb_resource_free(); #if !defined(_WIN32) notify_uninit(); #endif + + g_object_unref(ud->builder); + + g_free(ud->current_dvd_device); g_free(ud); return 0; diff --git a/gtk/src/presets.c b/gtk/src/presets.c index c59b917f2..560eec832 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -1061,9 +1061,8 @@ ghb_preset_to_settings(GValue *settings, GValue *preset) char *x264Tune = ghb_settings_get_string(settings, "x264Tune"); char *tune = NULL; - char *tmp = g_strdup(x264Tune); char *saveptr; - char * tok = strtok_r(tmp, ",./-+", &saveptr); + char * tok = strtok_r(x264Tune, ",./-+", &saveptr); while (tok != NULL) { if (!strcasecmp(tok, "fastdecode")) @@ -1084,12 +1083,12 @@ ghb_preset_to_settings(GValue *settings, GValue *preset) } tok = strtok_r(NULL, ",./-+", &saveptr); } + g_free(x264Tune); if (tune != NULL) { ghb_settings_set_string(settings, "x264Tune", tune); g_free(tune); } - g_free(x264Tune); } void @@ -3110,7 +3109,6 @@ settings_save(signal_user_data_t *ud, const GValue *path) { GValue *dict; gint *indices, len, count; - gint *def_indices, def_len; const gchar *name; gboolean replace = FALSE; @@ -3158,6 +3156,7 @@ settings_save(signal_user_data_t *ud, const GValue *path) ghb_dict_insert(dict, g_strdup("PresetName"), ghb_string_value_new(name)); if (replace) { + gint *def_indices, def_len; def_indices = presets_find_default(presetsPlist, &def_len); if (def_indices != NULL && preset_path_cmp(indices, len, def_indices, def_len) != 0) @@ -3166,6 +3165,7 @@ settings_save(signal_user_data_t *ud, const GValue *path) ghb_boolean_value_new(FALSE)); } presets_list_update_item(ud, indices, len, FALSE); + g_free(def_indices); } else { @@ -3446,6 +3446,7 @@ preset_import_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) ghb_presets_insert(presetsPlist, ghb_value_dup(dict), indices, len); presets_list_insert(ud, indices, len); ghb_value_free(path); + g_free(indices); } ghb_value_free(array); @@ -3612,8 +3613,7 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) folder_save(ud, dest); ghb_value_free(dest); } - if (indices != NULL) - g_free(indices); + g_free(indices); } G_MODULE_EXPORT void @@ -3732,6 +3732,7 @@ presets_remove_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) path = gtk_tree_model_get_path(store, &iter); indices = gtk_tree_path_get_indices(path); len = gtk_tree_path_get_depth(path); + gtk_tree_path_free(path); folder = ghb_presets_get_folder(presetsPlist, indices, len); dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, @@ -3764,15 +3765,17 @@ presets_remove_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) valid = gtk_tree_model_get_iter_first(store, &nextIter); if (valid) { - gtk_tree_path_free(path); + GtkTreePath *path; + gint *indices; + path = gtk_tree_model_get_path(store, &nextIter); indices = gtk_tree_path_get_indices(path); len = gtk_tree_path_get_depth(path); ghb_select_preset2(ud->builder, indices, len); + gtk_tree_path_free(path); } } g_free(preset); - gtk_tree_path_free(path); } } @@ -3850,6 +3853,7 @@ presets_drag_motion_cb( len = gtk_tree_path_get_depth(path); dst_ptype = ghb_presets_get_type(presetsPlist, indices, len); dst_folder = ghb_presets_get_folder(presetsPlist, indices, len); + // Don't allow mixing custom presets in the builtins if (dst_ptype != PRESETS_CUSTOM) { @@ -3957,6 +3961,7 @@ presets_drag_cb( dst_indices = gtk_tree_path_get_indices(path); dst_len = gtk_tree_path_get_depth(path); dst_folder = ghb_presets_get_folder(presetsPlist, dst_indices, dst_len); + // Only allow *drop into* for folders if (!dst_folder) { @@ -4040,7 +4045,9 @@ presets_row_expanded_cb( if (preset_folder_is_open(dict)) { if (expanded) + { return; + } } else if (!expanded) { @@ -4098,6 +4105,7 @@ ghb_get_current_preset(signal_user_data_t *ud) indices = gtk_tree_path_get_indices(tp); len = gtk_tree_path_get_depth(tp); preset = presets_get_dict(presetsPlist, indices, len); + gtk_tree_path_free(tp); } return preset; } @@ -4122,6 +4130,7 @@ ghb_get_current_preset_path(signal_user_data_t *ud) indices = gtk_tree_path_get_indices(tp); len = gtk_tree_path_get_depth(tp); path = preset_path_from_indices(presetsPlist, indices, len); + gtk_tree_path_free(tp); } return path; } diff --git a/gtk/src/preview.c b/gtk/src/preview.c index a63f61b2d..cf046f24a 100644 --- a/gtk/src/preview.c +++ b/gtk/src/preview.c @@ -240,8 +240,8 @@ ghb_preview_cleanup(signal_user_data_t *ud) { if (ud->preview->current) { - ud->preview->current = NULL; g_free(ud->preview->current); + ud->preview->current = NULL; } } @@ -987,7 +987,7 @@ ghb_set_preview_image(signal_user_data_t *ud) { widget = GHB_WIDGET (ud->builder, "preview_button_image"); gtk_image_set_from_pixbuf(GTK_IMAGE(widget), scaled_preview); - g_object_unref (scaled_preview); + g_object_unref(scaled_preview); } } } diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index 9725bd1bd..507b3cc08 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -195,6 +195,7 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) escape = g_markup_escape_text(dest, -1); g_string_append_printf(str, "<b>Destination:</b> <small>%s</small>\n", escape); + g_free(escape); width = ghb_settings_get_int(settings, "scale_width"); height = ghb_settings_get_int(settings, "scale_height"); @@ -388,6 +389,7 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) g_string_append_printf(str, "<b>Video:</b> <small>%s, Framerate: %s, %s %s%s</small>\n", vcodec, fps, vq_desc, vqstr, vq_units); + g_free(vqstr); turbo = ghb_settings_get_boolean(settings, "VideoTurboTwoPass"); if (turbo) @@ -427,12 +429,12 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) } else { - const char *br; + char *br; br = ghb_settings_get_string(asettings, "AudioBitrate"); quality = g_strdup_printf("Bitrate: %s", br); + g_free(br); } sr = ghb_settings_get_double(asettings, "AudioSamplerate"); - samplerate = ghb_settings_get_string(asettings, "AudioSamplerate"); if ((int)sr == 0) { samplerate = g_strdup("Same As Source"); @@ -776,8 +778,8 @@ queue_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud) gtk_tree_store_remove(GTK_TREE_STORE(store), &iter); // Remove the corresponding item from the queue list GValue *old = ghb_array_get_nth(ud->queue, row); - ghb_value_free(old); ghb_array_remove(ud->queue, row); + ghb_value_free(old); ghb_save_queue(ud->queue); } else @@ -1293,6 +1295,10 @@ find_pid: } g_free(message); } + else + { + ghb_value_free(queue); + } return FALSE; } diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c index 9fc959666..6065f5a4a 100644 --- a/gtk/src/subtitlehandler.c +++ b/gtk/src/subtitlehandler.c @@ -1165,7 +1165,9 @@ ghb_subtitle_prune(signal_user_data_t *ud) burned = burned || !hb_subtitle_can_pass(source, mux); if (burned && one_burned) { + GValue *gsub = ghb_array_get_nth(subtitle_list, ii); ghb_array_remove(subtitle_list, ii); + ghb_value_free(gsub); continue; } one_burned = one_burned || burned; @@ -1319,7 +1321,10 @@ subtitle_remove_lang_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) // Remove from preset language list lang_list = ghb_settings_get_value(ud->settings, "SubtitleLanguageList"); + GValue *glang = ghb_array_get_nth(lang_list, index); ghb_array_remove(lang_list, index); + ghb_value_free(glang); + ghb_clear_presets_selection(ud); if (ghb_array_len(lang_list) > 0) @@ -1401,7 +1406,9 @@ static void subtitle_def_lang_list_init(signal_user_data_t *ud) { // Error in list. Probably duplicate languages. Remove // this item from the list. + GValue *glang = ghb_array_get_nth(lang_list, ii); ghb_array_remove(lang_list, ii); + ghb_value_free(glang); count--; } } @@ -1519,8 +1526,8 @@ subtitle_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *u // immediate selection change, so the list needs to be up to date // when this happens. GValue *old = ghb_array_get_nth(subtitle_list, row); - ghb_value_free(old); ghb_array_remove(subtitle_list, row); + ghb_value_free(old); // Remove the selected item gtk_tree_store_remove(GTK_TREE_STORE(tm), &ti); diff --git a/gtk/src/values.c b/gtk/src/values.c index 85886e17e..3b5c5df38 100644 --- a/gtk/src/values.c +++ b/gtk/src/values.c @@ -713,7 +713,11 @@ ghb_array_copy(GValue *arr1, GValue *arr2, gint count) // empty the first array if it is not already empty len = ghb_array_len(arr1); for (ii = 0; ii < len; ii++) + { + GValue *old = ghb_array_get_nth(arr1, 0); ghb_array_remove(arr1, 0); + ghb_value_free(old); + } len = ghb_array_len(arr2); count = MIN(count, len); diff --git a/gtk/src/x264handler.c b/gtk/src/x264handler.c index 51a523f25..ad3e92ca2 100644 --- a/gtk/src/x264handler.c +++ b/gtk/src/x264handler.c @@ -197,6 +197,7 @@ x264_setting_changed_cb(GtkWidget *widget, signal_user_data_t *ud) else new_tt = g_strdup_printf("%s\n\nExpanded Options:\n\"\"", tt); gtk_widget_set_tooltip_text(eo, new_tt); + g_free(new_tt); g_free(opts); } @@ -327,6 +328,7 @@ x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud) else new_tt = g_strdup_printf("%s\n\nExpanded Options:\n\"\"", tt); gtk_widget_set_tooltip_text(eo, new_tt); + g_free(new_tt); g_free(options); options = sopts; |