Mercurial > hg > orthanc-stone
comparison Applications/IBasicApplication.cpp @ 61:ca644004d2ee wasm
MAJOR - removal of Start/Stop and observers in IWidget
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 10 May 2017 17:55:13 +0200 |
parents | d20e25cfcf3a |
children | 298f375dcb68 |
comparison
equal
deleted
inserted
replaced
60:288c948199e5 | 61:ca644004d2ee |
---|---|
224 if (title.empty()) | 224 if (title.empty()) |
225 { | 225 { |
226 title = "Stone of Orthanc"; | 226 title = "Stone of Orthanc"; |
227 } | 227 } |
228 | 228 |
229 context.Start(); | |
230 | |
231 { | 229 { |
232 /************************************************************** | 230 /************************************************************** |
233 * Run the application inside a SDL window | 231 * Run the application inside a SDL window |
234 **************************************************************/ | 232 **************************************************************/ |
235 | 233 |
236 LOG(WARNING) << "Starting the application"; | 234 LOG(WARNING) << "Starting the application"; |
237 | 235 |
238 SdlWindow window(title.c_str(), width, height, opengl); | 236 SdlWindow window(title.c_str(), width, height, opengl); |
239 SdlEngine sdl(window, context); | 237 SdlEngine sdl(window, context); |
240 | 238 |
239 { | |
240 BasicApplicationContext::ViewportLocker locker(context); | |
241 locker.GetViewport().Register(sdl); // (*) | |
242 } | |
243 | |
244 context.Start(); | |
241 sdl.Run(); | 245 sdl.Run(); |
242 | 246 |
243 LOG(WARNING) << "Stopping the application"; | 247 LOG(WARNING) << "Stopping the application"; |
248 | |
249 // Don't move the "Stop()" command below out of the block, | |
250 // otherwise the application might crash, because the | |
251 // "SdlEngine" is an observer of the viewport (*) and the | |
252 // update thread started by "context.Start()" would call a | |
253 // destructed object (the "SdlEngine" is deleted with the | |
254 // lexical scope). | |
255 context.Stop(); | |
244 } | 256 } |
245 | 257 |
246 | 258 |
247 /**************************************************************** | 259 /**************************************************************** |
248 * Finalize the application | 260 * Finalize the application |
249 ****************************************************************/ | 261 ****************************************************************/ |
250 | 262 |
251 context.Stop(); | |
252 | |
253 LOG(WARNING) << "The application has stopped"; | 263 LOG(WARNING) << "The application has stopped"; |
254 | |
255 { | |
256 BasicApplicationContext::ViewportLocker locker(context); | |
257 locker.GetViewport().ResetStatusBar(); | |
258 } | |
259 | |
260 application.Finalize(); | 264 application.Finalize(); |
261 } | 265 } |
262 catch (Orthanc::OrthancException& e) | 266 catch (Orthanc::OrthancException& e) |
263 { | 267 { |
264 LOG(ERROR) << "EXCEPTION: " << e.What(); | 268 LOG(ERROR) << "EXCEPTION: " << e.What(); |