From b5f45b1315fe0fdb6aab957d40f43eb7de5aeb56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Csord=C3=A1s?= Date: Tue, 12 Jun 2018 15:32:38 +0200 Subject: [PATCH] Fix non existing report in the GUI If no report can be found based on the given URL, remove the report hash and the report id from the URL. --- www/scripts/codecheckerviewer/ListOfBugs.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/www/scripts/codecheckerviewer/ListOfBugs.js b/www/scripts/codecheckerviewer/ListOfBugs.js index d47002d1cd..b0aa1cd03e 100644 --- a/www/scripts/codecheckerviewer/ListOfBugs.js +++ b/www/scripts/codecheckerviewer/ListOfBugs.js @@ -467,8 +467,12 @@ function (declare, dom, style, Deferred, ObjectStore, Store, QueryResults, if (sender && sender !== that._grid) return; - if (reportData !== null && !(reportData instanceof CC_OBJECTS.ReportData)) - reportData = CC_SERVICE.getReport(reportData); + if (reportData !== null && + !(reportData instanceof CC_OBJECTS.ReportData)) { + try { + reportData = CC_SERVICE.getReport(reportData); + } catch (ex) { console.warn(ex); } + } var getAndUseReportHash = reportHash && (!reportData || reportData.reportId === null || reportData.bugHash !== reportHash); @@ -479,7 +483,7 @@ function (declare, dom, style, Deferred, ObjectStore, Store, QueryResults, reportFilter.reportHash = [reportHash]; reportFilter.isUnique = false; - if (reportData) + if (reportData && reportData.checkedFile) reportFilter.filepath = ['*' + reportData.checkedFile]; // We set a sort option to select a report which has the shortest @@ -511,6 +515,16 @@ function (declare, dom, style, Deferred, ObjectStore, Store, QueryResults, that.reportData = reportData; + // No report has been found. + if (!reportData) { + console.warn('No report can be found: ' + reportHash); + hashHelper.setStateValues({ + 'reportHash' : null, + 'report' : null + }); + return; + } + var filename = reportData.checkedFile.substr( reportData.checkedFile.lastIndexOf('/') + 1);