Solving issue 1276: "Segfault on going back in history after pasting profile"

This commit is contained in:
natureh
2012-03-18 19:10:16 +01:00
parent 303673870d
commit 9da3425f78

View File

@@ -302,7 +302,6 @@ void ProfilePanel::load_clicked (GdkEventButton* event) {
dialog.hide(); dialog.hide();
if (result==Gtk::RESPONSE_OK) { if (result==Gtk::RESPONSE_OK) {
bool prevState = changeconn.block(true);
Glib::ustring fname = dialog.get_filename(); Glib::ustring fname = dialog.get_filename();
options.loadSaveProfilePath = Glib::path_get_dirname(fname); options.loadSaveProfilePath = Glib::path_get_dirname(fname);
@@ -322,8 +321,10 @@ void ProfilePanel::load_clicked (GdkEventButton* event) {
} }
int err = custom->load (fname); int err = custom->load (fname);
if (!err) { if (!err) {
profiles->append_text (Glib::ustring("(") + M("PROFILEPANEL_PCUSTOM") + ")"); bool prevState = changeconn.block(true);
profiles->set_active_text (Glib::ustring("(") + M("PROFILEPANEL_PCUSTOM") + ")"); Glib::ustring newEntry = Glib::ustring("(") + M("PROFILEPANEL_PCUSTOM") + ")";
profiles->append_text (newEntry);
profiles->set_active_text (newEntry);
old = profiles->get_active_text(); old = profiles->get_active_text();
changeconn.block(prevState); changeconn.block(prevState);
@@ -365,16 +366,22 @@ void ProfilePanel::paste_clicked (GdkEventButton* event) {
return; return;
} }
bool prevState = changeconn.block(true);
Glib::ustring newEntry = Glib::ustring("(") + M("PROFILEPANEL_PCUSTOM") + ")";
if (!custom) { if (!custom) {
custom = new PartialProfile (true); custom = new PartialProfile (true);
custom->pedited->set(true); custom->pedited->set(true);
profiles->append_text (Glib::ustring("(") + M("PROFILEPANEL_PCUSTOM") + ")"); profiles->append_text (newEntry);
} }
ProcParams pp = clipboard.getProcParams (); ProcParams pp = clipboard.getProcParams ();
custom->pparams = &pp; *custom->pparams = pp;
profiles->set_active_text (Glib::ustring("(") + M("PROFILEPANEL_PCUSTOM") + ")");
profiles->set_active_text (newEntry);
old = profiles->get_active_text(); old = profiles->get_active_text();
changeconn.block(prevState);
if (event->state & Gdk::CONTROL_MASK) { if (event->state & Gdk::CONTROL_MASK) {
// applying partial profile // applying partial profile
PartialProfile ppTemp(true); PartialProfile ppTemp(true);
@@ -399,14 +406,15 @@ void ProfilePanel::changeTo (PartialProfile* newpp, Glib::ustring profname) {
void ProfilePanel::selection_changed () { void ProfilePanel::selection_changed () {
if (profiles->get_active_text() == Glib::ustring("(") + M("PROFILEPANEL_PCUSTOM") + ")") { Glib::ustring entry;
if (profiles->get_active_text() == (entry = Glib::ustring("(") + M("PROFILEPANEL_PCUSTOM") + ")")) {
if (!dontupdate) if (!dontupdate)
changeTo (custom, Glib::ustring("(") + M("PROFILEPANEL_PCUSTOM") + ")"); changeTo (custom, entry);
} }
else if (profiles->get_active_text() == Glib::ustring("(") + M("PROFILEPANEL_PLASTSAVED") + ")") else if (profiles->get_active_text() == (entry = Glib::ustring("(") + M("PROFILEPANEL_PLASTSAVED") + ")"))
changeTo (lastsaved, Glib::ustring("(") + M("PROFILEPANEL_PLASTSAVED") + ")"); changeTo (lastsaved, entry);
else if (profiles->get_active_text() == Glib::ustring("(") + M("PROFILEPANEL_PLASTPHOTO") + ")") else if (profiles->get_active_text() == (entry = Glib::ustring("(") + M("PROFILEPANEL_PLASTPHOTO") + ")"))
changeTo (lastphoto, Glib::ustring("(") + M("PROFILEPANEL_PLASTPHOTO") + ")"); changeTo (lastphoto, entry);
else { else {
PartialProfile* s = profileStore.getProfile (profiles->get_active_text()); PartialProfile* s = profileStore.getProfile (profiles->get_active_text());
if (s) if (s)
@@ -422,17 +430,18 @@ void ProfilePanel::procParamsChanged (rtengine::procparams::ProcParams* p, rteng
if (ev==EvProfileChanged || ev==EvPhotoLoaded) if (ev==EvProfileChanged || ev==EvPhotoLoaded)
return; return;
if (profiles->get_active_text() != Glib::ustring("(") + M("PROFILEPANEL_PCUSTOM") + ")") { Glib::ustring entry = Glib::ustring("(") + M("PROFILEPANEL_PCUSTOM") + ")";
if (profiles->get_active_text() != entry) {
dontupdate = true; dontupdate = true;
if (!custom) { if (!custom) {
custom = new PartialProfile (true); custom = new PartialProfile (true);
custom->set(true); custom->set(true);
profiles->append_text (Glib::ustring("(") + M("PROFILEPANEL_PCUSTOM") + ")"); profiles->append_text (entry);
} }
profiles->set_active_text (Glib::ustring("(") + M("PROFILEPANEL_PCUSTOM") + ")"); profiles->set_active_text (entry);
old = profiles->get_active_text(); old = profiles->get_active_text();
} }
*(custom->pparams) = *p; *custom->pparams = *p;
} }
/* /*
@@ -483,7 +492,7 @@ void ProfilePanel::initProfile (const Glib::ustring& profname, ProcParams* lastS
if (lastsaved) { if (lastsaved) {
defline = Glib::ustring("(") + M("PROFILEPANEL_PLASTSAVED") + ")"; defline = Glib::ustring("(") + M("PROFILEPANEL_PLASTSAVED") + ")";
defprofile = lastsaved; defprofile = lastsaved;
profiles->append_text (Glib::ustring("(") + M("PROFILEPANEL_PLASTSAVED") + ")"); profiles->append_text (defline);
} }
if (tpc) { if (tpc) {