On Thu, Oct 22, 2015 at 09:21:41AM +0200, Robert C. Helling wrote: > Dirk, > > > On 22 Oct 2015, at 09:15, Dirk Hohndel <[email protected]> wrote: > > > > Why? What does the compiler complain about? The existing code is correct > > and unambiguous. What am I missing? > > one could worry to which if the else applies (yes, there is a rule but people > often get this wrong. And since this is not python the compiler does not look > at your beautiful indentation).
Yes. It is well defined, and clear to the reader, but still, in theory one could misinterpret it. In practice C binds else to the closest if, so the code is actually correct. I will once again rewrite Guido's patches into one simpler one that makes it unambiguous... basically the second patch without the first :-) /D commit f1c682b55a52c11d7cb57da0fc66d6edb118ba77 Author: Guido Lerch <[email protected]> Date: Thu Oct 22 00:17:05 2015 +0200 Fixing annoying compiler warning Adding { } to if clause to avoid dangling warning /Users/guidolerch/src/subsurface/qt-models/cylindermodel.cpp:117: warning: add explicit braces to avoid dangling else [-Wdangling-else] [Dirk Hohndel: combined two of Guido's patches to one that is simpler] Signed-off-by: Guido Lerch <[email protected]> Signed-off-by: Dirk Hohndel <[email protected]> diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index 8c9bee8b1882..8341d36081eb 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -111,18 +111,20 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const } break; case Qt::DecorationRole: - if (index.column() == REMOVE) + if (index.column() == REMOVE) { if (rowCount() > 1) ret = trashIcon(); else ret = trashForbiddenIcon(); + } break; case Qt::SizeHintRole: - if (index.column() == REMOVE) + if (index.column() == REMOVE) { if (rowCount() > 1) ret = trashIcon(); else ret = trashForbiddenIcon(); + } break; case Qt::ToolTipRole: _______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
