Adds usage of ADS_Expects precondition check.

This commit is contained in:
mfreiholz 2016-04-21 09:16:45 +02:00
parent 3a5cd2118a
commit f983a6ff85
2 changed files with 23 additions and 0 deletions

View File

@ -39,6 +39,10 @@ class QSplitter;
// Width of the native window frame border (based on OS).
#define ADS_WINDOW_FRAME_BORDER_WIDTH 7
// Beautiful C++ stuff.
#define ADS_Expects(cond)
#define ADS_Ensures(cond)
// Indicates whether ADS should include animations.
//#define ADS_ANIMATIONS_ENABLED 1
//#define ADS_ANIMATION_DURATION 150

View File

@ -69,6 +69,7 @@ ContainerWidget::~ContainerWidget()
SectionWidget* ContainerWidget::addSectionContent(const SectionContent::RefPtr& sc, SectionWidget* sw, DropArea area)
{
ADS_Expects(!sc.isNull());
if (!sw)
{
if (_sections.isEmpty())
@ -98,6 +99,8 @@ SectionWidget* ContainerWidget::addSectionContent(const SectionContent::RefPtr&
bool ContainerWidget::removeSectionContent(const SectionContent::RefPtr& sc)
{
ADS_Expects(!sc.isNull());
// Hide the content.
// The hideSectionContent() automatically deletes no longer required SectionWidget objects.
if (!hideSectionContent(sc))
@ -141,6 +144,8 @@ bool ContainerWidget::removeSectionContent(const SectionContent::RefPtr& sc)
bool ContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
{
ADS_Expects(!sc.isNull());
// Search SC in floatings
for (int i = 0; i < _floatings.count(); ++i)
{
@ -194,6 +199,8 @@ bool ContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
bool ContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc)
{
ADS_Expects(!sc.isNull());
// Search SC in floatings
// We can simply hide floatings, nothing else required.
for (int i = 0; i < _floatings.count(); ++i)
@ -248,6 +255,8 @@ bool ContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc)
bool ContainerWidget::raiseSectionContent(const SectionContent::RefPtr& sc)
{
ADS_Expects(!sc.isNull());
// Search SC in sections
for (int i = 0; i < _sections.count(); ++i)
{
@ -280,6 +289,8 @@ bool ContainerWidget::raiseSectionContent(const SectionContent::RefPtr& sc)
bool ContainerWidget::isSectionContentVisible(const SectionContent::RefPtr& sc)
{
ADS_Expects(!sc.isNull());
// Search SC in floatings
for (int i = 0; i < _floatings.count(); ++i)
{
@ -481,6 +492,8 @@ SectionWidget* ContainerWidget::newSectionWidget()
SectionWidget* ContainerWidget::dropContent(const InternalContentData& data, SectionWidget* targetSection, DropArea area, bool autoActive)
{
ADS_Expects(targetSection != NULL);
SectionWidget* ret = NULL;
// Drop on outer area
@ -605,6 +618,8 @@ SectionWidget* ContainerWidget::dropContent(const InternalContentData& data, Sec
void ContainerWidget::addSection(SectionWidget* section)
{
ADS_Expects(section != NULL);
// Create default splitter.
if (!_splitter)
{
@ -635,6 +650,8 @@ SectionWidget* ContainerWidget::sectionAt(const QPoint& pos) const
SectionWidget* ContainerWidget::dropContentOuterHelper(QLayout* l, const InternalContentData& data, Qt::Orientation orientation, bool append)
{
ADS_Expects(l != NULL);
SectionWidget* sw = newSectionWidget();
sw->addContent(data, true);
@ -1200,6 +1217,8 @@ bool ContainerWidget::restoreSectionWidgets(QDataStream& in, int version, QSplit
bool ContainerWidget::takeContent(const SectionContent::RefPtr& sc, InternalContentData& data)
{
ADS_Expects(!sc.isNull());
// Search in sections
bool found = false;
for (int i = 0; i < _sections.count() && !found; ++i)