Commit e2c891f6 authored by Davis King's avatar Davis King

Added try/catch blocks to the constructors of GUI window objects.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402521
parent e8f39c05
...@@ -171,7 +171,7 @@ int WINAPI WinMain (HINSTANCE, HINSTANCE, PSTR cmds, int) ...@@ -171,7 +171,7 @@ int WINAPI WinMain (HINSTANCE, HINSTANCE, PSTR cmds, int)
main_window:: main_window::
main_window( main_window(
) : ) try :
color_non_evidence(0,0,0), color_non_evidence(0,0,0),
color_default_bg(255,255,255), color_default_bg(255,255,255),
color_evidence(100,200,100), color_evidence(100,200,100),
...@@ -261,7 +261,7 @@ main_window( ...@@ -261,7 +261,7 @@ main_window(
// to all arrange themselves correctly in our window. // to all arrange themselves correctly in our window.
no_node_selected(); no_node_selected();
on_window_resized(); on_window_resized();
} } catch (...) { close_window(); } // make sure close_window() is called if something throws
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
...@@ -100,7 +100,7 @@ class win : public drawable_window ...@@ -100,7 +100,7 @@ class win : public drawable_window
*/ */
public: public:
win( win(
) : ) try :
c(*this), c(*this),
b(*this), b(*this),
cb(*this,rectangle(100,100,200,200),0,0,255), // the color_box will be blue and 101 pixels wide and tall cb(*this,rectangle(100,100,200,200),0,0,255), // the color_box will be blue and 101 pixels wide and tall
...@@ -144,7 +144,7 @@ public: ...@@ -144,7 +144,7 @@ public:
set_title("dlib gui example"); set_title("dlib gui example");
show(); show();
} } catch (...) { close_window(); } // make sure close window is called if something throws
~win( ~win(
) )
......
...@@ -33,7 +33,7 @@ public: ...@@ -33,7 +33,7 @@ public:
template <typename image_type> template <typename image_type>
win( win(
const image_type& img const image_type& img
) : ) try :
gui_img(*this) gui_img(*this)
{ {
// set the size of this window to match the size of the input image // set the size of this window to match the size of the input image
...@@ -46,7 +46,7 @@ public: ...@@ -46,7 +46,7 @@ public:
// show this window on the screen // show this window on the screen
show(); show();
} } catch (...) { close_window(); } // make sure close_window() is called if something throws
~win( ~win(
) )
...@@ -76,7 +76,7 @@ int main(int argc, char** argv) ...@@ -76,7 +76,7 @@ int main(int argc, char** argv)
} }
// Here we open the image file. Note that when you open a binary file with // Here we open the image file. Note that when you open a binary file with
// the C++ ifstream you must suplly the ios::binary flag. // the C++ ifstream you must supply the ios::binary flag.
ifstream fin(argv[1],ios::binary); ifstream fin(argv[1],ios::binary);
if (!fin) if (!fin)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment