Skip to content

Commit

Permalink
Merge branch 'master' into gl2-model
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 14, 2014
2 parents 9ade7ca + bd0a65d commit baa5399
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 12 deletions.
2 changes: 0 additions & 2 deletions doomsday/client/src/ui/widgets/consolewidget.cpp
Expand Up @@ -43,8 +43,6 @@ using namespace de;

static TimeDelta const LOG_OPEN_CLOSE_SPAN = 0.2;

static uint const POS_SCRIPT_MODE = 5;

DENG_GUI_PIMPL(ConsoleWidget),
DENG2_OBSERVES(Variable, Change)
{
Expand Down
12 changes: 8 additions & 4 deletions doomsday/client/src/ui/widgets/tutorialwidget.cpp
Expand Up @@ -130,16 +130,20 @@ DENG_GUI_PIMPL(TutorialWidget)
}

current = s;
bool const isFinalStep = (current == Finish - 1);

dlg = new MessageDialog;
dlg->useInfoStyle();
dlg->setDeleteAfterDismissed(true);
dlg->setClickToClose(false);
QObject::connect(dlg, SIGNAL(accepted(int)), thisPublic, SLOT(continueToNextStep()));
QObject::connect(dlg, SIGNAL(rejected(int)), thisPublic, SLOT(stop()));
dlg->buttons()
<< new DialogButtonItem(DialogWidget::Accept | DialogWidget::Default,
(current == Finish - 1)? tr("Done") : tr("Continue"))
<< new DialogButtonItem(DialogWidget::Reject | DialogWidget::Action, tr("Skip Tutorial"));
dlg->buttons() << new DialogButtonItem(DialogWidget::Accept | DialogWidget::Default,
isFinalStep? tr("Done") : tr("Continue"));
if(!isFinalStep)
{
dlg->buttons() << new DialogButtonItem(DialogWidget::Reject | DialogWidget::Action, tr("Skip Tutorial"));
}

// Insert the content for the dialog.
ClientWindow &win = ClientWindow::main();
Expand Down
3 changes: 3 additions & 0 deletions doomsday/libdeng2/include/de/data/record.h
Expand Up @@ -298,6 +298,9 @@ class DENG2_PUBLIC Record : public ISerializable, public LogEntry::Arg::Base,
*/
Variable &set(String const &name, bool value);

/// @copydoc set()
Variable &set(String const &name, char const *value);

/// @copydoc set()
Variable &set(String const &name, Value::Text const &value);

Expand Down
5 changes: 3 additions & 2 deletions doomsday/libdeng2/include/de/data/recordvalue.h
Expand Up @@ -89,9 +89,10 @@ class DENG2_PUBLIC RecordValue : public Value, DENG2_OBSERVES(Record, Deletion)
/**
* Sets the record that the value is referencing.
*
* @param record Record to reference. Ownership is not given.
* @param record Record to reference. Ownership is not given.
* @param ownership OwnsRecord, if the value is given ownership of @a record.
*/
void setRecord(Record *record);
void setRecord(Record *record, OwnershipFlags ownership = 0);

/**
* Gives away ownership of the record, if the value owns the record.
Expand Down
25 changes: 25 additions & 0 deletions doomsday/libdeng2/src/data/record.cpp
Expand Up @@ -213,6 +213,22 @@ void Record::copyMembersFrom(Record const &other, CopyBehavior behavior)
i.key().startsWith("__")) continue;

Variable *var = new Variable(*i.value());

// Ownerships of copied subrecords should be retained in the copy.
if(RecordValue *recVal = var->value().maybeAs<RecordValue>())
{
DENG2_ASSERT(!recVal->hasOwnership()); // RecordValue duplication behavior

RecordValue const &original = i.value()->value().as<RecordValue>();
if(original.hasOwnership())
{
DENG2_ASSERT(recVal->record() == original.record());

// Make a true copy of the subrecord.
recVal->setRecord(new Record(*recVal->record()), RecordValue::OwnsRecord);
}
}

var->audienceForDeletion() += this;
d->members[i.key()] = var;
}
Expand Down Expand Up @@ -435,6 +451,15 @@ Variable &Record::set(String const &name, bool value)
return addBoolean(name, value);
}

Variable &Record::set(String const &name, char const *value)
{
if(hasMember(name))
{
return (*this)[name].set(TextValue(value));
}
return addText(name, value);
}

Variable &Record::set(String const &name, Value::Text const &value)
{
if(hasMember(name))
Expand Down
6 changes: 3 additions & 3 deletions doomsday/libdeng2/src/data/recordvalue.cpp
Expand Up @@ -62,7 +62,7 @@ bool RecordValue::usedToHaveOwnership() const
return _oldOwnership.testFlag(OwnsRecord);
}

void RecordValue::setRecord(Record *record)
void RecordValue::setRecord(Record *record, OwnershipFlags ownership)
{
if(record == _record) return; // Got it already.

Expand All @@ -76,9 +76,9 @@ void RecordValue::setRecord(Record *record)
}

_record = record;
_ownership = 0;
_ownership = ownership;

if(_record)
if(_record && !_ownership.testFlag(OwnsRecord))
{
// Since we don't own it, someone may delete the record.
_record->audienceForDeletion() += this;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libgui/include/de/gui/libgui.h
Expand Up @@ -43,7 +43,7 @@
#endif

// Assertion specific to GL errors.
#ifdef Q_WS_X11
#if defined(Q_WS_X11) || defined(WIN32)
// Under X11 we're having more OpenGL errors; should investigate why.
# define LIBGUI_ASSERT_GL(cond) // ignored
#else
Expand Down
10 changes: 10 additions & 0 deletions doomsday/tests/test_record/main.cpp
Expand Up @@ -62,6 +62,16 @@ int main(int argc, char **argv)

Reader(b) >> rec2;
LOG_MSG("After being deserialized:\n") << rec2;

Record before;
before.addRecord("subrecord");
before.subrecord("subrecord").set("value", true);
DENG2_ASSERT(before.hasSubrecord("subrecord"));
LOG_MSG("Before copying:\n") << before;

Record copied = before;
DENG2_ASSERT(copied.hasSubrecord("subrecord"));
LOG_MSG("Copied:\n") << copied;
}
catch(Error const &err)
{
Expand Down

0 comments on commit baa5399

Please sign in to comment.