Changeset 385:5f0e735f46e1 in SMSSender for gateways/Schoolnet/gui/ui/widgets/questionbox.cpp


Ignore:
Timestamp:
Apr 16, 2014 11:29:11 AM (5 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.