diff --git a/bindgen.cc b/bindgen.cc index 29f88cd..52a14e1 100644 --- a/bindgen.cc +++ b/bindgen.cc @@ -526,7 +526,7 @@ static std::string function_source(xl_node_t* node) { } if(type2.type == "widget") { - strm << type2.name + "->GetWidget()"; + strm << "(" + type2.name + " == NULL ? NULL : " + type2.name + "->GetWidget())"; } else { if(type2.type == "string") { strm << std::endl; diff --git a/src/dialog/colorpicker.cc b/src/dialog/colorpicker.cc index 45d7d22..6b86852 100644 --- a/src/dialog/colorpicker.cc +++ b/src/dialog/colorpicker.cc @@ -1,7 +1,7 @@ #include MwCXX::Window* MwCXX::ColorPicker(MwCXX::Base* handle, MwCXX::String title) { - return new MwCXX::Window(MwColorPicker(handle->GetWidget(), + return new MwCXX::Window(MwColorPicker((handle == NULL ? NULL : handle->GetWidget()), #ifdef MWCXX_USE_C_STRING title #else diff --git a/src/dialog/directorychooser.cc b/src/dialog/directorychooser.cc index 61b4fc4..1261b87 100644 --- a/src/dialog/directorychooser.cc +++ b/src/dialog/directorychooser.cc @@ -1,7 +1,7 @@ #include MwCXX::Window* MwCXX::DirectoryChooser(MwCXX::Base* handle, MwCXX::String title) { - return new MwCXX::Window(MwDirectoryChooser(handle->GetWidget(), + return new MwCXX::Window(MwDirectoryChooser((handle == NULL ? NULL : handle->GetWidget()), #ifdef MWCXX_USE_C_STRING title #else diff --git a/src/dialog/filechooser.cc b/src/dialog/filechooser.cc index ecc4009..b36c739 100644 --- a/src/dialog/filechooser.cc +++ b/src/dialog/filechooser.cc @@ -1,7 +1,7 @@ #include MwCXX::Window* MwCXX::FileChooser(MwCXX::Base* handle, MwCXX::String title) { - return new MwCXX::Window(MwFileChooser(handle->GetWidget(), + return new MwCXX::Window(MwFileChooser((handle == NULL ? NULL : handle->GetWidget()), #ifdef MWCXX_USE_C_STRING title #else @@ -11,7 +11,7 @@ MwCXX::Window* MwCXX::FileChooser(MwCXX::Base* handle, MwCXX::String title) { handle); } MwCXX::Window* MwCXX::FileChooserEx(MwCXX::Base* handle, MwCXX::String title, int dir) { - return new MwCXX::Window(MwFileChooserEx(handle->GetWidget(), + return new MwCXX::Window(MwFileChooserEx((handle == NULL ? NULL : handle->GetWidget()), #ifdef MWCXX_USE_C_STRING title #else diff --git a/src/dialog/messagebox.cc b/src/dialog/messagebox.cc index 3c3f0bb..1fb221b 100644 --- a/src/dialog/messagebox.cc +++ b/src/dialog/messagebox.cc @@ -1,7 +1,7 @@ #include MwCXX::Window* MwCXX::MessageBox(MwCXX::Base* handle, MwCXX::String text, MwCXX::String title, unsigned int flag) { - return new MwCXX::Window(MwMessageBox(handle->GetWidget(), + return new MwCXX::Window(MwMessageBox((handle == NULL ? NULL : handle->GetWidget()), #ifdef MWCXX_USE_C_STRING text #else @@ -18,8 +18,8 @@ MwCXX::Window* MwCXX::MessageBox(MwCXX::Base* handle, MwCXX::String text, MwCXX: handle); } MwCXX::Button* MwCXX::MessageBoxGetChild(MwCXX::Window* handle, int child) { - return new MwCXX::Button(MwMessageBoxGetChild(handle->GetWidget(), (int)child), handle); + return new MwCXX::Button(MwMessageBoxGetChild((handle == NULL ? NULL : handle->GetWidget()), (int)child), handle); } void MwCXX::MessageBoxDestroy(MwCXX::Window* handle) { - MwMessageBoxDestroy(handle->GetWidget()); + MwMessageBoxDestroy((handle == NULL ? NULL : handle->GetWidget())); } diff --git a/src/widget/base.cc b/src/widget/base.cc index 74c2049..7a5e880 100644 --- a/src/widget/base.cc +++ b/src/widget/base.cc @@ -107,11 +107,13 @@ void MwCXX::Base::ForceRender() { void MwCXX::Base::Reparent(MwCXX::Base* new_parent) { int i; - for(i = 0; i < this->parent->children.size(); i++) { - if(this->parent->children[i] == this) { - this->parent->children.erase(this->parent->children.begin() + i); + if(this->parent != NULL) { + for(i = 0; i < this->parent->children.size(); i++) { + if(this->parent->children[i] == this) { + this->parent->children.erase(this->parent->children.begin() + i); - break; + break; + } } }