Changeset 359:bf2e79b1e768 in SMSSender


Ignore:
Timestamp:
Mar 31, 2014 11:04:59 PM (5 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
separation-frontend-backend
Message:
  • Fixes crash when saving a new contact or group.
Location:
frontend/gui/ui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • frontend/gui/ui/addressbook.h

    r319 r359  
    4949    SContact *getContactFromRow(int rowId) const;
    5050    SContact *getSelectedContact() const;
    51     void editContact(SContact *contact);
     51    bool editContact(SContact *contact);
    5252
    5353    SGroup *getGroupFromRow(int rowId) const;
    5454    SGroup *getSelectedGroup() const;
    55     void editGroup(SGroup *group);
     55    bool editGroup(SGroup *group);
    5656
    5757private slots:
  • frontend/gui/ui/addressbook_contact.cpp

    r317 r359  
    4343
    4444
    45 void AddressBook::editContact(SContact *contact) {
     45bool AddressBook::editContact(SContact *contact) {
    4646    QScopedPointer<EditContact> ec(new EditContact(this, contact, false, *m_contactManager, *m_groupManager));
    47     if (ec->exec() == QDialog::Accepted){ // Wait for return
     47    bool ok = ec->exec() == QDialog::Accepted;
     48
     49    if (ok) {
    4850        m_contactManager->saveContact(contact);
    4951    }
     52
     53    return ok;
    5054}
    5155
     
    5458
    5559void AddressBook::on_btnAddContact_clicked(){
    56     if (!ui.btnAddContact->isEnabled())
     60    if (!ui.btnAddContact->isEnabled()) {
    5761        return;
     62    }
    5863
    59     SContact newContact;
    60     editContact(&newContact);
     64    QScopedPointer<SContact> contact(new SContact);
     65    if (editContact(contact.data())) {
     66        contact.take();
     67    }
    6168}
    6269
  • frontend/gui/ui/addressbook_group.cpp

    r317 r359  
    4040
    4141
    42 void AddressBook::editGroup(SGroup *group){
     42bool AddressBook::editGroup(SGroup *group){
    4343    QScopedPointer<EditGroup> eg(new EditGroup(this, group, *m_groupManager, *m_contactManager));
    44     if (eg->exec() == QDialog::Accepted){ // Wait for return
     44    bool ok = eg->exec() == QDialog::Accepted;
     45
     46    if (ok) {
    4547        m_groupManager->saveGroup(group);
    4648    }
     49
     50    return ok;
    4751}
    4852
     
    5054// Slots
    5155void AddressBook::on_btnAddGroup_clicked(){
    52     if (!ui.btnAddGroup->isEnabled())
     56    if (!ui.btnAddGroup->isEnabled()) {
    5357        return;
     58    }
    5459
    55     SGroup newGroup;
    56     editGroup(&newGroup);
     60    QScopedPointer<SGroup> group(new SGroup);
     61    if (editGroup(group.data())) {
     62        group.take();
     63    }
    5764}
    5865
Note: See TracChangeset for help on using the changeset viewer.