uppsrc: Fixed various valgrind detected issues

This commit is contained in:
Mirek Fidler 2022-09-20 11:41:29 +02:00
parent ba7df93ab4
commit b3bdf28dbf
10 changed files with 20 additions and 11 deletions

View file

@ -74,14 +74,15 @@ static void sSeed(uint64 *s)
force_inline
static uint64 *sState()
{
static bool forked;
thread_local uint64 *s;
if(!s) {
if(!s || forked && Thread::IsMain()) {
thread_local uint64 state[4];
s = state;
sSeed(s);
#ifdef PLATFORM_POSIX
if(Thread::IsMain()) // non-main threads do not work with fork anyway
pthread_atfork(NULL, NULL, [] { sSeed(s); }); // reseed random generator after fork
pthread_atfork(NULL, NULL, [] { forked = true; }); // reseed random generator after fork
#endif
}
return s;

View file

@ -529,6 +529,7 @@ Ctrl::Ctrl() {
destroying = false;
multi_frame = false;
frame.frame = &NullFrame();
frame.SetView(Null);
enabled = visible = wantfocus = initfocus = true;
editable = true;
backpaint = IsCompositedGui() ? FULLBACKPAINT : TRANSPARENTBACKPAINT;

View file

@ -10,6 +10,7 @@ Ctrl::Frame Ctrl::AllocFrames(int alloc)
size_t sz0 = alloc * sizeof(Frame);
size_t sz = sz0;
m.frames = (Frame *)MemoryAllocSz(sz);
// memset(m.frames, 0, sz); _DBG_
m.multi.alloc = alloc + (int)((sz - sz0) / sizeof(Frame));
return m;
}
@ -42,6 +43,7 @@ void Ctrl::InsertFrame(int i, CtrlFrame& fr)
else
memmove(frame.frames + i + 1, frame.frames + i, (frame.multi.count - i) * sizeof(Frame));
frame.frames[i].frame = &fr;
frame.frames[i].SetView(Null);
frame.multi.count++;
}
fr.FrameAdd(*this);

View file

@ -114,6 +114,8 @@ Draw& ImageDraw::Alpha()
if(!alpha_surface) {
alpha_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, isz.cx, isz.cy);
alpha.cr = cairo_create(alpha_surface);
cairo_set_source_rgb(alpha.cr, 0, 0, 0);
cairo_paint(alpha.cr);
}
return alpha;
}
@ -181,6 +183,8 @@ void ImageDraw::Init(Size sz)
isz = sz;
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, isz.cx, isz.cy);
cr = cairo_create(surface);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_paint(cr);
alpha_surface = NULL;
del = true;
}

View file

@ -1053,11 +1053,11 @@ void EditField::Reset()
errorbg = nobg = false;
charset = CHARSET_UTF8;
alignright = false;
showspaces = false;
no_internal_margin = false;
SetStyle(StyleDefault());
SetFrame(edge);
font = StdFont();
showspaces = false;
no_internal_margin = false;
fsell = fselh = -1;
DeleteAttr<Image>(ATTR_NULLICON);
}

View file

@ -18,6 +18,7 @@ TreeCtrl::TreeCtrl()
multiroot = false;
chldlck = false;
highlight_ctrl = false;
hasctrls = false;
Clear();
SetFrame(ViewFrame());
AddFrame(sb);

View file

@ -33,7 +33,7 @@ void ImageBuffer::Create(int cx, int cy)
ASSERT(cx >= 0 && cy >= 0);
size.cx = cx;
size.cy = cy;
pixels.Alloc(GetLength());
pixels.Alloc(GetLength(), RGBAZero());
#ifdef _DEBUG
RGBA *s = pixels;
RGBA *e = pixels + GetLength();

View file

@ -207,6 +207,7 @@ void CurrentFileThread()
current_file_event.Wait();
LLOG("Current file Thread::IsShutdownThreads() " << Thread::IsShutdownThreads());
}
s_cf.Clear();
LLOG("Current file thread exit");
}
@ -221,7 +222,6 @@ void SetCurrentFile(const CurrentFileContext& ctx, Event<const CppFileInfo&> don
Thread::Start([] { CurrentFileThread(); });
Thread::AtShutdown([] {
LLOG("Shutdown current file");
s_cf.Clear();
current_file_event.Broadcast();
});
}

View file

@ -135,10 +135,10 @@ struct AnnotationItem : Moveable<AnnotationItem> {
String nest; // Upp::Class
String unest; // UPP::CLASS
String bases; // base classes of struct/class
Point pos;
int kind;
bool definition;
bool isvirtual;
Point pos = Null;
int kind = Null;
bool definition = false;
bool isvirtual = false;
void Serialize(Stream& s);
};

View file

@ -531,7 +531,7 @@ public:
LineEdit::EditPos editpos;
Point columnline;
LineEdit::UndoData undodata;
int64 filehash; // make sure undodata work
int64 filehash = 0; // make sure undodata work
LineInfo lineinfo;
LineInfoRem lineinforem;