Skip to content

Commit d4a08a1

Browse files
committed
Stub's gui::Gui::get() now asserts enabled() and address some fallout.
Signed-off-by: Ted Hong <[email protected]>
1 parent de23da8 commit d4a08a1

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/gpl/src/graphicsImpl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ namespace gpl {
2727
GraphicsImpl::GraphicsImpl(utl::Logger* logger)
2828
: HeatMapDataSource(logger, "gpl", "gpl"), logger_(logger), mode_(Mbff)
2929
{
30-
gui::Gui::get()->registerRenderer(this);
30+
if (gui::Gui::enabled()) {
31+
gui::Gui::get()->registerRenderer(this);
32+
}
3133
}
3234

3335
GraphicsImpl::~GraphicsImpl() = default;

src/gui/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ cc_library(
3030
deps = [
3131
"//src/odb",
3232
"@boost.multi_array",
33+
"@com_google_absl//absl/log:check",
3334
"@tk_tcl//:tcl",
3435
],
3536
)

src/gui/src/gui.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,9 @@ static void resetConversions()
210210

211211
Gui* Gui::get()
212212
{
213-
static Gui* singleton_ = new Gui();
214-
return singleton_;
213+
static Gui* singleton = new Gui();
214+
215+
return singleton;
215216
}
216217

217218
Gui::Gui()

src/gui/src/stub.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <typeinfo>
1313
#include <vector>
1414

15+
#include "absl/log/check.h"
1516
#include "gui/gui.h"
1617
#include "odb/db.h"
1718
#include "odb/geom.h"
@@ -52,8 +53,10 @@ Gui::Gui() : continue_after_close_(false), logger_(nullptr), db_(nullptr)
5253

5354
Gui* gui::Gui::get()
5455
{
55-
static Gui* singleton_ = new Gui();
56-
return singleton_;
56+
CHECK(enabled())
57+
<< "Internal Error: gui::Gui::get() called when enabled() is false";
58+
59+
return nullptr;
5760
}
5861

5962
bool gui::Gui::enabled()

0 commit comments

Comments
 (0)