[EXAMPLES]
* BUG: Fix the Database example. [INTERPRETER] * BUG: Fix unchecked system calls. [ARCHIVER] * BUG: Prevent the archiver from putting the executable file into itself, leading to a endless growing generated file. * NEW: Files having the ".gambas" extension are now excluded from executable archives. [GB.DB.FORM] * BUG: Remove the DataBrowser.Adjust property. git-svn-id: svn://localhost/gambas/trunk@3272 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
583fcf419d
commit
8aac47f84d
1
TODO
1
TODO
@ -42,6 +42,7 @@ GUI RELATED STUFF
|
||||
- ValueBox.Value should be visible in the IDE.
|
||||
- GridView automatic column resizing by code in gb.gtk, and in gb.qt.
|
||||
- Moveable tabs.
|
||||
- ListView and GridView selection interface should be the same.
|
||||
|
||||
DESKTOP COMPONENT
|
||||
|
||||
|
@ -21,10 +21,6 @@ Orientation
|
||||
p
|
||||
i
|
||||
|
||||
Adjust
|
||||
p
|
||||
b
|
||||
|
||||
Editable
|
||||
p
|
||||
b
|
||||
@ -32,7 +28,7 @@ b
|
||||
_Properties
|
||||
C
|
||||
s
|
||||
*,Control=True,Adjust,Columns{Field[]},Editable,Header=True,Orientation{Align.Bottom;Left;Right;Top}=Bottom
|
||||
*,Control=True,Columns{Field[]},Editable,Header=True,Orientation{Align.Bottom;Left;Right;Top}=Bottom
|
||||
_Group
|
||||
C
|
||||
s
|
||||
|
@ -10,6 +10,10 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: .project:1
|
||||
msgid "Data bound controls"
|
||||
msgstr ""
|
||||
|
||||
#: DataControl.class:84 DataView.class:354
|
||||
msgid "True"
|
||||
msgstr ""
|
||||
@ -117,7 +121,3 @@ msgstr ""
|
||||
#: FTest.class:76
|
||||
msgid "Remove"
|
||||
msgstr ""
|
||||
|
||||
#: .project:1
|
||||
msgid "Data bound controls"
|
||||
msgstr ""
|
||||
|
@ -9,10 +9,9 @@ Property Control As Boolean
|
||||
Property Read View As TableView
|
||||
Property Header As Boolean
|
||||
Property Orientation As Integer
|
||||
Property Adjust As Boolean
|
||||
Property Editable As Boolean
|
||||
|
||||
Public Const _Properties As String = "*,Control=True,Adjust,Columns{Field[]},Editable,Header=True,Orientation{Align.Bottom;Left;Right;Top}=Bottom"
|
||||
Public Const _Properties As String = "*,Control=True,Columns{Field[]},Editable,Header=True,Orientation{Align.Bottom;Left;Right;Top}=Bottom"
|
||||
Public Const _Group As String = "Data"
|
||||
|
||||
Private $hForm As FBrowser
|
||||
@ -97,17 +96,17 @@ Private Sub Orientation_Write(Value As Integer)
|
||||
|
||||
End
|
||||
|
||||
Private Function Adjust_Read() As Boolean
|
||||
|
||||
Return $hForm.DataView.Adjust
|
||||
|
||||
End
|
||||
|
||||
Private Sub Adjust_Write(Value As Boolean)
|
||||
|
||||
$hForm.DataView.Adjust = Value
|
||||
|
||||
End
|
||||
' Private Function Adjust_Read() As Boolean
|
||||
'
|
||||
' Return $hForm.DataView.Adjust
|
||||
'
|
||||
' End
|
||||
'
|
||||
' Private Sub Adjust_Write(Value As Boolean)
|
||||
'
|
||||
' $hForm.DataView.Adjust = Value
|
||||
'
|
||||
' End
|
||||
|
||||
Public Sub _OnDatabaseChange()
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Gambas Project File 3.0
|
||||
# Compiled with Gambas 2.99.0 (r3194)
|
||||
# Compiled with Gambas 2.99.0
|
||||
Startup=FMain
|
||||
Icon=database.png
|
||||
Version=0.0.1
|
||||
|
@ -82,35 +82,35 @@ Public Sub tbvData_Data(Row As Integer, Column As Integer)
|
||||
End
|
||||
|
||||
|
||||
Private Function WidthFromType(hCtrl As control, iType As Integer, iLength As Integer, sTitle As String) As Integer
|
||||
Private Function WidthFromType(hCtrl As Control, iType As Integer, iLength As Integer, sTitle As String) As Integer
|
||||
|
||||
Dim iWidth As Integer
|
||||
|
||||
Select Case iType
|
||||
|
||||
Case gb.Boolean
|
||||
iWidth = hCtrl.Font.Width(Str(False)) + 32
|
||||
iWidth = hCtrl.Font.TextWidth(Str(False)) + 32
|
||||
|
||||
Case gb.Integer
|
||||
iWidth = hCtrl.Font.Width("1234567890") + 16
|
||||
iWidth = hCtrl.Font.TextWidth("1234567890") + 16
|
||||
|
||||
Case gb.Long
|
||||
iWidth = hCtrl.Font.Width("12345678901234567890") + 16
|
||||
iWidth = hCtrl.Font.TextWidth("12345678901234567890") + 16
|
||||
|
||||
Case gb.Float
|
||||
iWidth = hCtrl.Font.Width(CStr(Pi) & "E+999") + 16
|
||||
iWidth = hCtrl.Font.TextWidth(CStr(Pi) & "E+999") + 16
|
||||
|
||||
Case gb.Date
|
||||
iWidth = hCtrl.Font.Width(Str(Now)) + 16
|
||||
iWidth = hCtrl.Font.TextWidth(Str(Now)) + 16
|
||||
|
||||
Case gb.String
|
||||
If iLength = 0 Then iLength = 255
|
||||
iLength = Min(32, iLength)
|
||||
iWidth = hCtrl.Font.Width("X") * iLength + 16
|
||||
iWidth = hCtrl.Font.TextWidth("X") * iLength + 16
|
||||
|
||||
End Select
|
||||
|
||||
iWidth = Max(iWidth, hCtrl.Font.Width(sTitle) + 8)
|
||||
iWidth = Max(iWidth, hCtrl.Font.TextWidth(sTitle) + 8)
|
||||
|
||||
Return iWidth
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
@ -1,5 +1,5 @@
|
||||
# Gambas Project File 3.0
|
||||
# Compiled with Gambas 2.99.0 (r3067)
|
||||
# Compiled with Gambas 2.99.0
|
||||
Title=Anti-Aliased Drawing
|
||||
Startup=FMain
|
||||
Icon=icon.png
|
||||
|
@ -63,7 +63,7 @@ static char **path_list;
|
||||
static int path_current;
|
||||
|
||||
static const char *allowed_hidden_files[] = { ".gambas", ".info", ".list", ".lang", ".action", ".connection", NULL };
|
||||
static const char *remove_ext_root[] = { "module", "class", "form", "gambas", NULL };
|
||||
//static const char *remove_ext_root[] = { "module", "class", "form", "gambas", NULL };
|
||||
static const char *remove_ext_lang[] = { "pot", "po", NULL };
|
||||
|
||||
static bool _extract = FALSE;
|
||||
@ -193,7 +193,7 @@ static void path_init(const char *first)
|
||||
ARRAY_create(&path_list);
|
||||
|
||||
if (*first)
|
||||
chdir(first);
|
||||
FILE_chdir(first);
|
||||
|
||||
path_add(FILE_get_current_dir());
|
||||
|
||||
@ -314,6 +314,10 @@ int main(int argc, char **argv)
|
||||
continue;
|
||||
|
||||
file = FILE_cat(path, file_name, NULL);
|
||||
|
||||
// Do not put the archive file inside itself.
|
||||
if (!strcmp(file, ARCH_output))
|
||||
continue;
|
||||
|
||||
if (stat(file_name, &info))
|
||||
{
|
||||
@ -335,9 +339,9 @@ int main(int argc, char **argv)
|
||||
|
||||
//printf("path = %s\n", &path[len_prefix]);
|
||||
|
||||
if (path[len_prefix] == 0)
|
||||
remove_ext = remove_ext_root;
|
||||
else if (strcmp(&path[len_prefix], "/.lang") == 0)
|
||||
//if (path[len_prefix] == 0)
|
||||
// remove_ext = remove_ext_root;
|
||||
if (strcmp(&path[len_prefix], "/.lang") == 0)
|
||||
remove_ext = remove_ext_lang;
|
||||
else
|
||||
remove_ext = 0;
|
||||
@ -353,6 +357,9 @@ int main(int argc, char **argv)
|
||||
if (*p != NULL)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(ext, "gambas") == 0)
|
||||
continue;
|
||||
|
||||
ARCH_add_file(file);
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ static void get_arguments(int argc, char **argv)
|
||||
|
||||
/*COMP_project = STR_copy(FILE_cat(argv[optind], "Gambas", NULL));*/
|
||||
if (optind < argc)
|
||||
chdir(argv[optind]);
|
||||
FILE_chdir(argv[optind]);
|
||||
|
||||
dir = FILE_get_current_dir();
|
||||
if (!dir)
|
||||
@ -374,17 +374,11 @@ static void init_files(const char *first)
|
||||
ARRAY_create(&_files);
|
||||
|
||||
if (*first)
|
||||
{
|
||||
if (chdir(first))
|
||||
{
|
||||
fprintf(stderr, "gbc: cannot switch to directory: %s\n", first);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
FILE_chdir(first);
|
||||
|
||||
recursive = chdir(".src") == 0;
|
||||
fill_files(FILE_get_current_dir(), recursive);
|
||||
if (recursive) chdir("..");
|
||||
if (recursive) FILE_chdir("..");
|
||||
|
||||
// Sort paths
|
||||
qsort(_files, ARRAY_count(_files), sizeof(*_files), (int (*)(const void *, const void *))compare_path);
|
||||
@ -424,7 +418,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
if (main_verbose)
|
||||
puts("Removing .info and .list files");
|
||||
chdir(FILE_get_dir(COMP_project));
|
||||
FILE_chdir(FILE_get_dir(COMP_project));
|
||||
unlink(".info");
|
||||
unlink(".list");
|
||||
}
|
||||
|
@ -45,6 +45,8 @@
|
||||
|
||||
/*#define DEBUG*/
|
||||
|
||||
#define TEMP_EXEC ".temp.gambas"
|
||||
|
||||
char *ARCH_project;
|
||||
char *ARCH_project_name;
|
||||
char *ARCH_output = NULL;
|
||||
@ -101,22 +103,46 @@ static void write_string(const char *str, int len)
|
||||
|
||||
static void make_executable(void)
|
||||
{
|
||||
const char *err;
|
||||
struct stat info;
|
||||
|
||||
if (stat(ARCH_output, &info) == 0)
|
||||
if (chmod(ARCH_output, info.st_mode | S_IXUSR | S_IXGRP | S_IXOTH) == 0)
|
||||
{
|
||||
FILE_set_owner(ARCH_output, FILE_cat(FILE_get_dir(ARCH_project), ".project", NULL));
|
||||
return;
|
||||
}
|
||||
FILE_chdir(FILE_get_dir(ARCH_project));
|
||||
|
||||
if (stat(TEMP_EXEC, &info) || chmod(TEMP_EXEC, info.st_mode | S_IXUSR | S_IXGRP | S_IXOTH))
|
||||
{
|
||||
err = "Cannot change executable permissions";
|
||||
goto __ERROR;
|
||||
}
|
||||
|
||||
THROW("Cannot make executable: &1", strerror(errno));
|
||||
FILE_set_owner(TEMP_EXEC, FILE_cat(FILE_get_dir(ARCH_project), ".project", NULL));
|
||||
|
||||
if (FILE_exist(ARCH_output) && unlink(ARCH_output))
|
||||
{
|
||||
err = "Cannot remove previous executable";
|
||||
goto __ERROR;
|
||||
}
|
||||
|
||||
if (rename(TEMP_EXEC, ARCH_output))
|
||||
{
|
||||
err = "Cannot create executable";
|
||||
goto __ERROR;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
__ERROR:
|
||||
|
||||
THROW("Cannot make executable: &1: &2", err, strerror(errno));
|
||||
}
|
||||
|
||||
|
||||
void ARCH_define_output(const char *path)
|
||||
{
|
||||
STR_free(ARCH_output);
|
||||
|
||||
if (path && *path != '/')
|
||||
path = FILE_cat(FILE_get_current_dir(), path, NULL);
|
||||
|
||||
ARCH_output = STR_copy(path);
|
||||
}
|
||||
|
||||
@ -129,7 +155,7 @@ void ARCH_define_project(const char *project)
|
||||
if (project == NULL)
|
||||
project = FILE_get_current_dir();
|
||||
|
||||
chdir(project);
|
||||
FILE_chdir(project);
|
||||
dir = STR_copy(FILE_get_current_dir());
|
||||
|
||||
arch_dir_pos = strlen(dir) + 1;
|
||||
@ -159,7 +185,7 @@ void ARCH_init(void)
|
||||
|
||||
ALLOC(&arch_buffer, 4096, "ARCH_init");
|
||||
|
||||
arch_file = fopen(ARCH_output, "w");
|
||||
arch_file = fopen(".temp.gambas", "w");
|
||||
if (arch_file == NULL)
|
||||
THROW("Cannot create temporary archive file: &1", ARCH_output);
|
||||
|
||||
|
@ -280,7 +280,7 @@ bool ARCHIVE_get(ARCHIVE *arch, const char **ppath, ARCHIVE_FIND *find)
|
||||
if (get_current(&arch, ppath))
|
||||
{
|
||||
// no archive found, we try a lstat
|
||||
chdir(PROJECT_path);
|
||||
FILE_chdir(PROJECT_path);
|
||||
if (stat(*ppath, &buf))
|
||||
return TRUE;
|
||||
|
||||
|
@ -354,8 +354,10 @@ BEGIN_PROPERTY(System_Domain)
|
||||
|
||||
char buffer[256];
|
||||
|
||||
getdomainname(buffer, 255);
|
||||
GB_ReturnNewZeroString(buffer);
|
||||
if (getdomainname(buffer, 255))
|
||||
GB_Error("Unable to retrieve domain name: &1", strerror(errno));
|
||||
else
|
||||
GB_ReturnNewZeroString(buffer);
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
|
@ -538,7 +538,7 @@ static void run_process(CPROCESS *process, int mode, void *cmd, CARRAY *env)
|
||||
}
|
||||
|
||||
// Return to the parent working directory
|
||||
chdir(PROJECT_oldcwd);
|
||||
FILE_chdir(PROJECT_oldcwd);
|
||||
|
||||
if (env)
|
||||
{
|
||||
@ -569,7 +569,8 @@ static void callback_child(int fd, int type, void *data)
|
||||
|
||||
/*old = signal(SIGCHLD, signal_child);*/
|
||||
|
||||
read(fd, (char *)&buffer, 1);
|
||||
if (read(fd, (char *)&buffer, 1) != 1)
|
||||
ERROR_panic("Cannot read from SIGCHLD pipe");
|
||||
|
||||
#ifdef DEBUG_ME
|
||||
fprintf(stderr, "<< callback_child\n");
|
||||
@ -615,7 +616,8 @@ static void signal_child(int sig)
|
||||
return;
|
||||
|
||||
buffer = 42;
|
||||
write(_pipe_child[1], &buffer, 1);
|
||||
if (write(_pipe_child[1], &buffer, 1) != 1)
|
||||
ERROR_panic("Cannot write into SIGCHLD pipe");
|
||||
}
|
||||
|
||||
|
||||
|
@ -532,13 +532,16 @@ static void load_and_relocate(CLASS *class, int len_data, int *pndesc, int *pfir
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = open("/tmp/gambas-bad-header.out", O_CREAT | O_WRONLY, 0666);
|
||||
fd = open("/tmp/gambas-bad-header.dump", O_CREAT | O_WRONLY, 0666);
|
||||
if (fd >= 0)
|
||||
{
|
||||
write(fd, class->data, len_data);
|
||||
if (write(fd, class->data, len_data) != len_data)
|
||||
fprintf(stderr, "Cannot dump bad class file.\n");
|
||||
else
|
||||
fprintf(stderr, "Bad class file dumped at /tmp/gambas-bad-header.dump\n");
|
||||
close(fd);
|
||||
fprintf(stderr, "Bad class file dumped at /tmp/gambas-bad-header.out: %d bytes\n", len_data);
|
||||
}
|
||||
|
||||
THROW(E_CLASS, ClassName, "Bad header", "");
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ void PROJECT_init(const char *file)
|
||||
{
|
||||
path = FILE_get_dir(file);
|
||||
|
||||
chdir(path);
|
||||
FILE_chdir(path);
|
||||
|
||||
path = FILE_getcwd(NULL);
|
||||
if (path == NULL)
|
||||
@ -389,7 +389,7 @@ void PROJECT_init(const char *file)
|
||||
|
||||
PROJECT_path = STRING_new(path, len);
|
||||
|
||||
chdir(PROJECT_path);
|
||||
FILE_chdir(PROJECT_path);
|
||||
|
||||
/* Project name */
|
||||
|
||||
|
@ -669,7 +669,7 @@ void SUBR_isdir(void)
|
||||
|
||||
path = get_path(PARAM);
|
||||
|
||||
isdir = FILE_isdir(path);
|
||||
isdir = FILE_is_dir(path);
|
||||
|
||||
RETURN->type = T_BOOLEAN;
|
||||
RETURN->_integer.value = isdir ? -1 : 0;
|
||||
|
@ -86,10 +86,10 @@ const char *FILE_set_ext(const char *path, const char *ext);
|
||||
|
||||
const char *FILE_getcwd(const char *subdir);
|
||||
#define FILE_get_current_dir() FILE_getcwd(NULL)
|
||||
void FILE_chdir(const char *path);
|
||||
|
||||
const char *FILE_readlink(const char *link);
|
||||
bool FILE_is_dir(const char *path);
|
||||
#define FILE_isdir FILE_is_dir
|
||||
|
||||
const char *FILE_find_gambas(void);
|
||||
|
||||
|
@ -433,7 +433,7 @@ bool FILE_exist_real(const char *path)
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
chdir(PROJECT_path);
|
||||
if (chdir(PROJECT_path)) return FALSE;
|
||||
return (stat(path, &buf) == 0);
|
||||
}
|
||||
|
||||
@ -941,3 +941,13 @@ const char *FILE_find_gambas(void)
|
||||
return path;
|
||||
}
|
||||
|
||||
void FILE_chdir(const char *path)
|
||||
{
|
||||
#ifdef PROJECT_EXEC
|
||||
if (chdir(path))
|
||||
THROW_SYSTEM(errno, path);
|
||||
#else
|
||||
if (chdir(path))
|
||||
THROW("Cannot change current directory: &1: &2", path, strerror(errno));
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user