diff dwtestoo.cpp @ 2866:6ea67d0809eb

Convert DW::App class into a singleton so subsequent DW::App::Init() calls will return a handle to our instance once it is already initialized.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 17 Dec 2022 11:51:22 +0000
parents fd32dce7fecd
children ada74f4d3f39
line wrap: on
line diff
--- a/dwtestoo.cpp	Sat Dec 17 09:03:32 2022 +0000
+++ b/dwtestoo.cpp	Sat Dec 17 11:51:22 2022 +0000
@@ -1,7 +1,5 @@
 #include <dw.hpp>
 
-DW::App *app;
-
 class MyWindow : public DW::Window
 {
 public:
@@ -10,13 +8,13 @@
 	SetSize(200, 200);
 	}
 protected:
-	virtual int OnDelete() { app->MainQuit(); return FALSE; }
+	virtual int OnDelete() { DW::App *app = DW::App::Init(); app->MainQuit(); return FALSE; }
 	virtual int OnConfigure(int width, int height)  { return FALSE; }
 };
 
 int dwmain(int argc, char* argv[])
 {
-  app = new DW::App(argc, argv, "org.dbsoft.dwindows.dwtestoo");
+  DW::App *app = DW::App::Init(argc, argv, "org.dbsoft.dwindows.dwtestoo");
   MyWindow *window = new MyWindow();
 
   window->Show();