Changeset 385:5f0e735f46e1 in SMSSender


Ignore:
Timestamp:
Apr 16, 2014 11:29:11 AM (4 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
separation-frontend-backend
Message:
  • Fixes crash when switching to another question in the Schoolnet send-integration and then providing the answer for it.
Location:
gateways/Schoolnet/gui/ui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • gateways/Schoolnet/gui/ui/senddialogintegration.cpp

    r384 r385  
    7272        Q_ASSERT(layout);
    7373
    74         m_questionBox.reset(new DeepThought::UI::QuestionBox(*m_question, sendDialog));
     74        m_questionBox.reset(new DeepThought::UI::QuestionBox(m_question, sendDialog));
    7575        connect(m_questionBox.data(), SIGNAL(answerProvided(DeepThought::Answer*)),
    7676                this, SLOT(onAnswerProvided(DeepThought::Answer*)),
     
    114114    m_question = !openQuestions.empty() ? openQuestions.first() : NULL;
    115115    if (m_question && m_questionBox) {
    116         m_questionBox->loadQuestion(*m_question);
     116        m_questionBox->loadQuestion(m_question);
    117117    }
    118118}
  • gateways/Schoolnet/gui/ui/widgets/questionbox.cpp

    r382 r385  
    2525namespace UI {
    2626
    27 QuestionBox::QuestionBox(const Question &question, QWidget *parent)
     27QuestionBox::QuestionBox(const Question *question, QWidget *parent)
    2828    : QWidget(parent)
    29     , m_question(question)
    3029    , m_hintLabel(NULL)
    3130{
     
    4039}
    4140
    42 void QuestionBox::loadQuestion(const Question &question) {
     41void QuestionBox::loadQuestion(const Question *question) {
     42    m_question = question;
     43
    4344    if (m_hintLabel) delete m_hintLabel;
    4445    while (!m_radios.isEmpty()) delete m_radios.takeFirst();
    4546
    46     ui.lblQuestion->setText(question.text());
     47    ui.lblQuestion->setText(question->text());
    4748
    48     if (!question.hint().isEmpty()) {
     49    if (!question->hint().isEmpty()) {
    4950        m_hintLabel = new QLabel(this);
    50         m_hintLabel->setText("<b>" + tr("Hint") + ": </b>" + question.hint());
     51        m_hintLabel->setText("<b>" + tr("Hint") + ": </b>" + question->hint());
    5152        m_hintLabel->setWordWrap(true);
    5253        m_hintLabel->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard);
     
    5556
    5657    QBoxLayout *answersLayout = qobject_cast<QBoxLayout*>(ui.grpAnswers->layout());
    57     foreach (const Answer *answer, question.answers()) {
     58    foreach (const Answer *answer, question->answers()) {
    5859        QRadioButton *radio = new QRadioButton(ui.grpAnswers);
    5960
     
    9394            }
    9495
    95             foreach (Answer *answer, m_question.answers()) {
     96            foreach (Answer *answer, m_question->answers()) {
    9697                if (answer->text() == radio->text()) {
    9798                    theAnswer = answer;
  • gateways/Schoolnet/gui/ui/widgets/questionbox.h

    r382 r385  
    3636
    3737public:
    38     QuestionBox(const Question &question, QWidget *parent);
     38    QuestionBox(const Question *question, QWidget *parent);
    3939    ~QuestionBox();
    4040
    4141    enum DialogCode { NextQuestion = QDialog::Accepted+1 };
    4242
    43     void loadQuestion(const Question &question);
     43    void loadQuestion(const Question *question);
    4444
    4545signals:
    46     void answerProvided(Answer *answer);
     46    void answerProvided(DeepThought::Answer *answer);
    4747    void rejected();
    4848    void nextQuestionRequested();
     
    5151    ::Ui::QuestionBoxClass ui; // TODO: Fix namespace
    5252
    53     const Question &m_question;
     53    const Question *m_question;
    5454
    5555    QLabel *m_hintLabel;
Note: See TracChangeset for help on using the changeset viewer.