ide/ProjectView: Fixed crash on Alt-Up/Down to select next project
authorJerome St-Louis <jerome@ecere.com>
Wed, 9 Jul 2014 13:28:05 +0000 (09:28 -0400)
committerJerome St-Louis <jerome@ecere.com>
Wed, 9 Jul 2014 13:28:21 +0000 (09:28 -0400)
ide/src/project/ProjectView.ec

index fce5747..9fe69e8 100644 (file)
@@ -1495,18 +1495,24 @@ class ProjectView : Window
    void SelectNextProject(bool backwards)
    {
       DataRow row = fileList.currentRow;
-      DataRow currentRow = row;
-      ProjectNode node = (ProjectNode)(intptr)row.tag;
-      if(node.type != project)
-         row = node.project.topNode.row;
-      else if(backwards)
-         row = row.previous ? row.previous : fileList.lastRow;
-      if(!backwards)
-         row = row.next ? row.next : fileList.firstRow;
-      if(row && row != currentRow)
-      {
-         fileList.SelectRow(row);
-         fileList.currentRow = row;
+      if(!row)
+         row = backwards ? fileList.lastRow : fileList.firstRow;
+
+      if(row)
+      {
+         DataRow currentRow = row;
+         ProjectNode node = (ProjectNode)(intptr)row.tag;
+         if(node.type != project)
+            row = node.project.topNode.row;
+         else if(backwards)
+            row = row.previous ? row.previous : fileList.lastRow;
+         if(!backwards)
+            row = row.next ? row.next : fileList.firstRow;
+         if(row && row != currentRow)
+         {
+            fileList.SelectRow(row);
+            fileList.currentRow = row;
+         }
       }
    }