diff --git a/include/nana/paint/graphics.hpp b/include/nana/paint/graphics.hpp index 4eafffa2..8843a03f 100644 --- a/include/nana/paint/graphics.hpp +++ b/include/nana/paint/graphics.hpp @@ -91,7 +91,11 @@ namespace nana const void* pixmap() const; const void* context() const; - void make(const ::nana::size&); ///< Creates a bitmap resource that size is width by height in pixel + /// Creates a graphics/drawable resource + /** + * @param sz The dimension of the graphics to be requested. If sz is empty, it performs as release(). + */ + void make(const ::nana::size& sz); void resize(const ::nana::size&); void typeface(const font&); ///< Selects a specified font type into the graphics object. font typeface() const; diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index 62940369..7fdadcea 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -291,6 +291,12 @@ namespace paint { if(impl_->handle == nullptr || impl_->size != sz) { + if (sz.empty()) + { + release(); + return; + } + //The object will be delete while dwptr_ is performing a release. drawable_type dw = new nana::detail::drawable_impl_type; //Reuse the old font @@ -342,7 +348,7 @@ namespace paint Display* disp = spec.open_display(); int screen = DefaultScreen(disp); Window root = ::XRootWindow(disp, screen); - dw->pixmap = ::XCreatePixmap(disp, root, (sz.width ? sz.width : 1), (sz.height ? sz.height : 1), DefaultDepth(disp, screen)); + dw->pixmap = ::XCreatePixmap(disp, root, sz.width, sz.height, DefaultDepth(disp, screen)); dw->context = ::XCreateGC(disp, dw->pixmap, 0, 0); #if defined(NANA_USE_XFT) dw->xftdraw = ::XftDrawCreate(disp, dw->pixmap, spec.screen_visual(), spec.colormap());