r22446 by craig - Coverity 1350103: logicially dead code

scribus-commit scribus-commit at lists.scribus.net
Mon Mar 26 21:26:03 UTC 2018


Author: craig
Date: Mon Mar 26 21:26:03 2018
New Revision: 22446

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22446
Log:
Coverity 1350103: logicially dead code

Modified:
    trunk/Scribus/scribus/appmodehelper.cpp

Modified: trunk/Scribus/scribus/appmodehelper.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22446&path=/trunk/Scribus/scribus/appmodehelper.cpp
==============================================================================
--- trunk/Scribus/scribus/appmodehelper.cpp	(original)
+++ trunk/Scribus/scribus/appmodehelper.cpp	Mon Mar 26 21:26:03 2018
@@ -1292,16 +1292,32 @@
 	// Determine state.
 	PageItem* item = doc ? doc->m_Selection->itemAt(0) : 0;
 	PageItem_Table* table = (item && item->isTable()) ? item->asTable() : 0;
-	const bool tableEdit = table && (doc->appMode == modeEditTable);
-	const int tableRows = table ? table->rows() : 0;
-	const int tableColumns = table ? table->columns() : 0;
+
+	if (!doc || !table)
+	{
+		(*a_scrActions)["tableInsertRows"]->setEnabled(false);
+		(*a_scrActions)["tableInsertColumns"]->setEnabled(false);
+		(*a_scrActions)["tableDeleteRows"]->setEnabled(false);
+		(*a_scrActions)["tableDeleteColumns"]->setEnabled(false);
+		(*a_scrActions)["tableMergeCells"]->setEnabled(false);
+		(*a_scrActions)["tableSplitCells"]->setEnabled(false); // Not implemented.
+		(*a_scrActions)["tableSetRowHeights"]->setEnabled(false);
+		(*a_scrActions)["tableSetColumnWidths"]->setEnabled(false);
+		(*a_scrActions)["tableDistributeRowsEvenly"]->setEnabled(false);
+		(*a_scrActions)["tableDistributeColumnsEvenly"]->setEnabled(false);
+		(*a_scrActions)["tableAdjustFrameToTable"]->setEnabled(false);
+		(*a_scrActions)["tableAdjustTableToFrame"]->setEnabled(false);
+		return;
+	}
+
+	const bool tableEdit = doc->appMode == modeEditTable;
+	const int tableRows = table->rows();
+	const int tableColumns = table->columns();
 	const int selectedRows = tableEdit ? table->selectedRows().size() : 0;
 	const int selectedColumns = tableEdit ? table->selectedColumns().size() : 0;
 	const int selectedCells = tableEdit ? table->selectedCells().size() : 0;
 
 	// Enable/disable menu actions.
-	(*a_scrActions)["tableInsertRows"]->setEnabled(table || (tableEdit && selectedCells < 1));
-	(*a_scrActions)["tableInsertColumns"]->setEnabled(table || (tableEdit && selectedCells < 1));
 	(*a_scrActions)["tableDeleteRows"]->setEnabled(tableEdit &&
 		((selectedRows < 1 && tableRows > 1) || (selectedRows > 0 && selectedRows < tableRows)));
 	(*a_scrActions)["tableDeleteColumns"]->setEnabled(tableEdit &&
@@ -1310,21 +1326,22 @@
 	(*a_scrActions)["tableSplitCells"]->setEnabled(false); // Not implemented.
 	(*a_scrActions)["tableSetRowHeights"]->setEnabled(tableEdit);
 	(*a_scrActions)["tableSetColumnWidths"]->setEnabled(tableEdit);
-	if (doc)
-	{
-		if (doc->appMode == modeEditTable)
-		{
-			(*a_scrActions)["tableDistributeRowsEvenly"]->setEnabled(selectedRows > 1);
-			(*a_scrActions)["tableDistributeColumnsEvenly"]->setEnabled(selectedColumns > 1);
-		}
-		else
-		{
-			(*a_scrActions)["tableDistributeRowsEvenly"]->setEnabled(table);
-			(*a_scrActions)["tableDistributeColumnsEvenly"]->setEnabled(table);
-		}
-	}
-	(*a_scrActions)["tableAdjustFrameToTable"]->setEnabled(table);
-	(*a_scrActions)["tableAdjustTableToFrame"]->setEnabled(table);
+	if (tableEdit)
+	{
+		(*a_scrActions)["tableInsertRows"]->setEnabled(selectedCells < 1);
+		(*a_scrActions)["tableInsertColumns"]->setEnabled(selectedCells < 1);
+		(*a_scrActions)["tableDistributeRowsEvenly"]->setEnabled(selectedRows > 1);
+		(*a_scrActions)["tableDistributeColumnsEvenly"]->setEnabled(selectedColumns > 1);
+	}
+	else
+	{
+		(*a_scrActions)["tableInsertRows"]->setEnabled(true);
+		(*a_scrActions)["tableInsertColumns"]->setEnabled(true);
+		(*a_scrActions)["tableDistributeRowsEvenly"]->setEnabled(true);
+		(*a_scrActions)["tableDistributeColumnsEvenly"]->setEnabled(true);
+	}
+	(*a_scrActions)["tableAdjustFrameToTable"]->setEnabled(true);
+	(*a_scrActions)["tableAdjustTableToFrame"]->setEnabled(true);
 }
 
 void AppModeHelper::changeLayer(ScribusDoc *doc, bool clipScrapHaveData)




More information about the scribus-commit mailing list