mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
CtrlCore: Ctrl::Lock fixes
git-svn-id: svn://ultimatepp.org/upp/trunk@1197 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
db8090d36b
commit
951b669351
11 changed files with 1122 additions and 1024 deletions
2024
newdraw/Draw/Draw.h
2024
newdraw/Draw/Draw.h
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,4 @@
|
|||
LAYOUT(LayoutTestLayout, 408, 252)
|
||||
LAYOUT(LayoutTestLayout, 344, 188)
|
||||
ITEM(Button, b2, SetLabel(t_("Cancel")).RightPosZ(4, 60).BottomPosZ(5, 19))
|
||||
ITEM(Button, b1, SetLabel(t_("OK")).LeftPosZ(4, 60).BottomPosZ(5, 19))
|
||||
END_LAYOUT
|
||||
|
|
|
|||
19
uppdev/MySQLSch/MySQLSch.cpp
Normal file
19
uppdev/MySQLSch/MySQLSch.cpp
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#include <MySql/MySql.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
MySqlSession session;
|
||||
// substitute your 'username' and 'password' here:
|
||||
if(!session.Connect("root", "heslo", "test", "10.0.0.19")) {
|
||||
printf("Can't connect with MySql\n");
|
||||
return;
|
||||
}
|
||||
Sql sql(session);
|
||||
sql.Execute("use test");
|
||||
sql.Execute("show tables");
|
||||
while(sql.Fetch())
|
||||
Cout() << (String)sql[0] << '\n';
|
||||
SaveFile("u:/lego.sch", ExportSch(session, "test"));
|
||||
}
|
||||
10
uppdev/MySQLSch/MySQLSch.upp
Normal file
10
uppdev/MySQLSch/MySQLSch.upp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
uses
|
||||
Core,
|
||||
MySql;
|
||||
|
||||
file
|
||||
MySQLSch.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
5
uppdev/MySQLSch/init
Normal file
5
uppdev/MySQLSch/init
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#ifndef _MySQLSch_icpp_init_stub
|
||||
#define _MySQLSch_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#include "MySql/init"
|
||||
#endif
|
||||
|
|
@ -179,7 +179,6 @@ LRESULT CALLBACK Ctrl::UtilityProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
|
|||
void Ctrl::InitWin32(HINSTANCE hInstance)
|
||||
{
|
||||
GuiLock __;
|
||||
ASSERT(Thread::IsMain());
|
||||
LLOG("InitWin32");
|
||||
// RLOGBLOCK("Ctrl::InitWin32");
|
||||
#define ILOG(x) // RLOG(x)
|
||||
|
|
@ -406,7 +405,7 @@ UDropTarget *NewUDropTarget(Ctrl *);
|
|||
void Ctrl::Create(HWND parent, DWORD style, DWORD exstyle, bool savebits, int show, bool dropshadow)
|
||||
{
|
||||
GuiLock __;
|
||||
ASSERT(Thread::IsMain());
|
||||
ASSERT(IsMainThread());
|
||||
LLOG("Ctrl::Create(parent = " << (void *)parent << ") in " <<UPP::Name(this) << BeginIndent);
|
||||
ASSERT(!IsChild() && !IsOpen());
|
||||
Rect r = GetRect();
|
||||
|
|
@ -691,7 +690,7 @@ bool Ctrl::ProcessEvents(bool *quit)
|
|||
void Ctrl::EventLoop(Ctrl *ctrl)
|
||||
{
|
||||
GuiLock __;
|
||||
ASSERT(Thread::IsMain());
|
||||
ASSERT(IsMainThread());
|
||||
ASSERT(LoopLevel == 0 || ctrl);
|
||||
LoopLevel++;
|
||||
LLOG("Entering event loop at level " << LoopLevel << BeginIndent);
|
||||
|
|
@ -724,7 +723,7 @@ void Ctrl::EventLoop(Ctrl *ctrl)
|
|||
void Ctrl::GuiSleep(int ms)
|
||||
{
|
||||
GuiLock __;
|
||||
ASSERT(Thread::IsMain());
|
||||
ASSERT(IsMainThread());
|
||||
ELOG("GuiSleep");
|
||||
if(EndSession())
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -103,12 +103,17 @@ void EnterGuiMutex(int n);
|
|||
void LeaveGuiMutex();
|
||||
int LeaveGuiMutexAll();
|
||||
|
||||
struct GuiLock {
|
||||
#ifdef _MULTITHREADED
|
||||
struct GuiLock {
|
||||
GuiLock() { EnterGuiMutex(); }
|
||||
~GuiLock() { LeaveGuiMutex(); }
|
||||
#endif
|
||||
};
|
||||
#else
|
||||
struct GuiLock {
|
||||
GuiLock() {}
|
||||
~GuiLock() {}
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef GuiLock DrawLock;
|
||||
|
||||
|
|
|
|||
9
upptst/GuiMtTest/GuiMtTest.upp
Normal file
9
upptst/GuiMtTest/GuiMtTest.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
main.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI MT";
|
||||
|
||||
4
upptst/GuiMtTest/init
Normal file
4
upptst/GuiMtTest/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _GuiMtTest_icpp_init_stub
|
||||
#define _GuiMtTest_icpp_init_stub
|
||||
#include "CtrlLib/init"
|
||||
#endif
|
||||
47
upptst/GuiMtTest/main.cpp
Normal file
47
upptst/GuiMtTest/main.cpp
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct App : TopWindow {
|
||||
Thread work;
|
||||
|
||||
void Work();
|
||||
|
||||
ArrayCtrl list;
|
||||
|
||||
typedef App CLASSNAME;
|
||||
|
||||
App();
|
||||
~App();
|
||||
};
|
||||
|
||||
void App::Work()
|
||||
{
|
||||
int q = 0;
|
||||
while(!Thread::IsShutdownThreads()) {
|
||||
for(int i = 0; i < 101; i++) {
|
||||
GuiLock __;
|
||||
list.Set(i, 0, (int)Random());
|
||||
}
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
App::App()
|
||||
{
|
||||
list.AddColumn("Test");
|
||||
Add(list.SizePos());
|
||||
work.Run(THISBACK(Work));
|
||||
}
|
||||
|
||||
App::~App()
|
||||
{
|
||||
Thread::ShutdownThreads();
|
||||
work.Wait();
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
App app;
|
||||
app.Run();
|
||||
}
|
||||
|
|
@ -40,14 +40,14 @@ GUI_APP_MAIN
|
|||
for(int i = 0; i < 18; i++) {
|
||||
int a, b;
|
||||
do {
|
||||
a = Random(100) + 1;
|
||||
b = Random(100) + 1;
|
||||
a = Random(200) + 1;
|
||||
b = Random(200) + 1;
|
||||
}
|
||||
while(a + b < 0 || a + b > 199);
|
||||
while(a + b < 90 || a + b > 400);
|
||||
r.DrawText(10, 10 + 3 * isz.cy / 2 * i, Format("%d + %d =", a, b), fnt);
|
||||
do {
|
||||
a = Random(100) + 1;
|
||||
b = Random(100) + 1;
|
||||
a = Random(200) + 1;
|
||||
b = Random(200) + 1;
|
||||
}
|
||||
while(a - b < 1);
|
||||
r.DrawText(2000, 10 + 3 * isz.cy / 2 * i, Format("%d - %d =", a, b), fnt);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue