Fixing some undefined behaviour, Issue 2277

This commit is contained in:
Ingo
2014-03-11 11:49:06 +01:00
parent 64562bd83f
commit aeeaf4de3c
14 changed files with 55 additions and 34 deletions

View File

@@ -21,7 +21,7 @@
#include "imagearea.h"
#include "cursormanager.h"
PreviewWindow::PreviewWindow () : previewHandler(NULL), mainCropWin(NULL), imageArea(NULL), isMoving(false) {
PreviewWindow::PreviewWindow () : previewHandler(NULL), mainCropWin(NULL), imageArea(NULL), isMoving(false), zoom(0.0) {
rconn = signal_size_allocate().connect( sigc::mem_fun(*this, &PreviewWindow::on_resized) );
}
@@ -36,7 +36,7 @@ void PreviewWindow::getObservedFrameArea (int& x, int& y, int& w, int& h) {
if (mainCropWin) {
int cropX, cropY, cropW, cropH;
mainCropWin->getCropRectangle (cropX, cropY, cropW, cropH);
mainCropWin->getCropRectangle (cropX, cropY, cropW, cropH);
// translate it to screen coordinates
x = imgX + cropX*zoom;
y = imgY + cropY*zoom;
@@ -100,12 +100,12 @@ bool PreviewWindow::on_expose_event (GdkEventExpose* event) {
window->draw_drawable (get_style()->get_base_gc(Gtk::STATE_NORMAL), backBuffer, 0, 0, 0, 0, -1, -1);
if (mainCropWin) {
if (mainCropWin && zoom > 0.0) {
Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
int x, y, w, h;
getObservedFrameArea (x, y, w, h);
cr->set_source_rgb (1.0, 1.0, 1.0);
cr->set_line_width (3);
cr->set_line_width (3);
cr->rectangle (x-1.5, y-1.5, w+2, h+2);
cr->stroke ();
cr->set_source_rgb (1.0, 0.0, 0.0);