gui: Add null check and print warning in DbNetDescriptor::highlight()#9388
Conversation
…The-OpenROAD-Project#9383) Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
There was a problem hiding this comment.
Code Review
This pull request adds a defensive null check in DbNetDescriptor::highlight() to prevent a crash when the net is null, which is a good safety measure. My review includes suggestions to improve how the logger is accessed, promoting better encapsulation and reducing dependencies by using an existing class member instead of a global singleton.
| #include "odb/dbWireGraph.h" | ||
| #include "odb/geom.h" | ||
| #include "options.h" | ||
| #include "ord/OpenRoad.hh" |
There was a problem hiding this comment.
sta_->getLogger() does not exist.
| utl::Logger* logger = ord::OpenRoad::openRoad()->getLogger(); | ||
| logger->warn( | ||
| utl::GUI, 111, "Net is nullptr in DbNetDescriptor::highlight()."); |
There was a problem hiding this comment.
The logger can be obtained more directly via the sta_ member, which is already available in this class. This avoids using the global OpenRoad singleton and including OpenRoad.hh.
| utl::Logger* logger = ord::OpenRoad::openRoad()->getLogger(); | |
| logger->warn( | |
| utl::GUI, 111, "Net is nullptr in DbNetDescriptor::highlight()."); | |
| sta_->getLogger()->warn(utl::GUI, 111, "Net is nullptr in DbNetDescriptor::highlight()."); |
| odb::dbObject* sink_object = getSink(object); | ||
| auto net = getObject(object); | ||
| if (net == nullptr) { | ||
| utl::Logger* logger = ord::OpenRoad::openRoad()->getLogger(); |
There was a problem hiding this comment.
The singleton should only be used from the .i files not in the c++ core.
|
All the descriptors assume they are given a non-null pointer. I prefer to fix this a level higher. |
Fixes #9383