--- nono/wx/wxvideomonitor.cpp 2026/04/29 17:04:28 1.1.1.1 +++ nono/wx/wxvideomonitor.cpp 2026/04/29 17:04:37 1.1.1.2 @@ -1,9 +1,9 @@ // // nono -// Copyright (C) 2019 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // -#include "wxheader.h" #include "wxvideomonitor.h" #include "bitmap.h" @@ -37,9 +37,6 @@ WXLunaBitmapPanel::WXLunaBitmapPanel(wxW // デストラクタ WXLunaBitmapPanel::~WXLunaBitmapPanel() { - if (bmpbuf) { - delete bmpbuf; - } } // サイズ変更イベント @@ -57,15 +54,12 @@ WXLunaBitmapPanel::OnSize(wxSizeEvent& e view_height = size.y; // BMP バッファを持っていれば一旦解放 - if (bmpbuf) { - delete bmpbuf; - bmpbuf = NULL; - } + bmpbuf.reset(); // BMP バッファ作成 // 正しく描かれなかった時に分かりやすいよう初期値は濃いグレーにしておく - bmpbuf = new uint8 [view_width * view_height * 3]; - memset(bmpbuf, 0x70, view_width * view_height * 3); + bmpbuf.reset(new uint8 [view_width * view_height * 3]); + memset(&bmpbuf[0], 0x70, view_width * view_height * 3); } // スクロールイベント @@ -92,7 +86,7 @@ WXLunaBitmapPanel::OnPaint(wxPaintEvent& // 更新があれば、ここで裏バッファに描画 Draw(); // バッファから wxBitmap を作成 - wxImage image(view_width, view_height, bmpbuf, true); + wxImage image(view_width, view_height, bmpbuf.get(), true); wxBitmap bitmap(image); // 実画面 DC にコピー @@ -110,7 +104,7 @@ WXLunaBitmapPanel::Draw() int x_offset = view_x / width_per_unit; for (int y = 0; y < height; y++) { - const uint32 *s = (uint32 *)&src[(view_y + y) * 256]; + const uint32 *s = (const uint32 *)&src[(view_y + y) * 256]; uint8 *d = &bmpbuf[y * (width * 3)]; // dst を1ラインクリアしてから..