[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:
Benoît Minisini 2010-10-31 22:05:29 +00:00
parent 583fcf419d
commit 8aac47f84d
19 changed files with 110 additions and 70 deletions

1
TODO
View File

@ -42,6 +42,7 @@ GUI RELATED STUFF
- ValueBox.Value should be visible in the IDE. - ValueBox.Value should be visible in the IDE.
- GridView automatic column resizing by code in gb.gtk, and in gb.qt. - GridView automatic column resizing by code in gb.gtk, and in gb.qt.
- Moveable tabs. - Moveable tabs.
- ListView and GridView selection interface should be the same.
DESKTOP COMPONENT DESKTOP COMPONENT

View File

@ -21,10 +21,6 @@ Orientation
p p
i i
Adjust
p
b
Editable Editable
p p
b b
@ -32,7 +28,7 @@ b
_Properties _Properties
C C
s 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 _Group
C C
s s

View File

@ -10,6 +10,10 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: .project:1
msgid "Data bound controls"
msgstr ""
#: DataControl.class:84 DataView.class:354 #: DataControl.class:84 DataView.class:354
msgid "True" msgid "True"
msgstr "" msgstr ""
@ -117,7 +121,3 @@ msgstr ""
#: FTest.class:76 #: FTest.class:76
msgid "Remove" msgid "Remove"
msgstr "" msgstr ""
#: .project:1
msgid "Data bound controls"
msgstr ""

View File

@ -9,10 +9,9 @@ Property Control As Boolean
Property Read View As TableView Property Read View As TableView
Property Header As Boolean Property Header As Boolean
Property Orientation As Integer Property Orientation As Integer
Property Adjust As Boolean
Property Editable 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" Public Const _Group As String = "Data"
Private $hForm As FBrowser Private $hForm As FBrowser
@ -97,17 +96,17 @@ Private Sub Orientation_Write(Value As Integer)
End End
Private Function Adjust_Read() As Boolean ' Private Function Adjust_Read() As Boolean
'
Return $hForm.DataView.Adjust ' Return $hForm.DataView.Adjust
'
End ' End
'
Private Sub Adjust_Write(Value As Boolean) ' Private Sub Adjust_Write(Value As Boolean)
'
$hForm.DataView.Adjust = Value ' $hForm.DataView.Adjust = Value
'
End ' End
Public Sub _OnDatabaseChange() Public Sub _OnDatabaseChange()

View File

@ -1,5 +1,5 @@
# Gambas Project File 3.0 # Gambas Project File 3.0
# Compiled with Gambas 2.99.0 (r3194) # Compiled with Gambas 2.99.0
Startup=FMain Startup=FMain
Icon=database.png Icon=database.png
Version=0.0.1 Version=0.0.1

View File

@ -82,35 +82,35 @@ Public Sub tbvData_Data(Row As Integer, Column As Integer)
End 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 Dim iWidth As Integer
Select Case iType Select Case iType
Case gb.Boolean Case gb.Boolean
iWidth = hCtrl.Font.Width(Str(False)) + 32 iWidth = hCtrl.Font.TextWidth(Str(False)) + 32
Case gb.Integer Case gb.Integer
iWidth = hCtrl.Font.Width("1234567890") + 16 iWidth = hCtrl.Font.TextWidth("1234567890") + 16
Case gb.Long Case gb.Long
iWidth = hCtrl.Font.Width("12345678901234567890") + 16 iWidth = hCtrl.Font.TextWidth("12345678901234567890") + 16
Case gb.Float Case gb.Float
iWidth = hCtrl.Font.Width(CStr(Pi) & "E+999") + 16 iWidth = hCtrl.Font.TextWidth(CStr(Pi) & "E+999") + 16
Case gb.Date Case gb.Date
iWidth = hCtrl.Font.Width(Str(Now)) + 16 iWidth = hCtrl.Font.TextWidth(Str(Now)) + 16
Case gb.String Case gb.String
If iLength = 0 Then iLength = 255 If iLength = 0 Then iLength = 255
iLength = Min(32, iLength) iLength = Min(32, iLength)
iWidth = hCtrl.Font.Width("X") * iLength + 16 iWidth = hCtrl.Font.TextWidth("X") * iLength + 16
End Select End Select
iWidth = Max(iWidth, hCtrl.Font.Width(sTitle) + 8) iWidth = Max(iWidth, hCtrl.Font.TextWidth(sTitle) + 8)
Return iWidth Return iWidth

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -1,5 +1,5 @@
# Gambas Project File 3.0 # Gambas Project File 3.0
# Compiled with Gambas 2.99.0 (r3067) # Compiled with Gambas 2.99.0
Title=Anti-Aliased Drawing Title=Anti-Aliased Drawing
Startup=FMain Startup=FMain
Icon=icon.png Icon=icon.png

View File

@ -63,7 +63,7 @@ static char **path_list;
static int path_current; static int path_current;
static const char *allowed_hidden_files[] = { ".gambas", ".info", ".list", ".lang", ".action", ".connection", NULL }; 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 const char *remove_ext_lang[] = { "pot", "po", NULL };
static bool _extract = FALSE; static bool _extract = FALSE;
@ -193,7 +193,7 @@ static void path_init(const char *first)
ARRAY_create(&path_list); ARRAY_create(&path_list);
if (*first) if (*first)
chdir(first); FILE_chdir(first);
path_add(FILE_get_current_dir()); path_add(FILE_get_current_dir());
@ -314,6 +314,10 @@ int main(int argc, char **argv)
continue; continue;
file = FILE_cat(path, file_name, NULL); 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)) if (stat(file_name, &info))
{ {
@ -335,9 +339,9 @@ int main(int argc, char **argv)
//printf("path = %s\n", &path[len_prefix]); //printf("path = %s\n", &path[len_prefix]);
if (path[len_prefix] == 0) //if (path[len_prefix] == 0)
remove_ext = remove_ext_root; // remove_ext = remove_ext_root;
else if (strcmp(&path[len_prefix], "/.lang") == 0) if (strcmp(&path[len_prefix], "/.lang") == 0)
remove_ext = remove_ext_lang; remove_ext = remove_ext_lang;
else else
remove_ext = 0; remove_ext = 0;
@ -353,6 +357,9 @@ int main(int argc, char **argv)
if (*p != NULL) if (*p != NULL)
continue; continue;
} }
if (strcmp(ext, "gambas") == 0)
continue;
ARCH_add_file(file); ARCH_add_file(file);
} }

View File

@ -215,7 +215,7 @@ static void get_arguments(int argc, char **argv)
/*COMP_project = STR_copy(FILE_cat(argv[optind], "Gambas", NULL));*/ /*COMP_project = STR_copy(FILE_cat(argv[optind], "Gambas", NULL));*/
if (optind < argc) if (optind < argc)
chdir(argv[optind]); FILE_chdir(argv[optind]);
dir = FILE_get_current_dir(); dir = FILE_get_current_dir();
if (!dir) if (!dir)
@ -374,17 +374,11 @@ static void init_files(const char *first)
ARRAY_create(&_files); ARRAY_create(&_files);
if (*first) if (*first)
{ FILE_chdir(first);
if (chdir(first))
{
fprintf(stderr, "gbc: cannot switch to directory: %s\n", first);
exit(1);
}
}
recursive = chdir(".src") == 0; recursive = chdir(".src") == 0;
fill_files(FILE_get_current_dir(), recursive); fill_files(FILE_get_current_dir(), recursive);
if (recursive) chdir(".."); if (recursive) FILE_chdir("..");
// Sort paths // Sort paths
qsort(_files, ARRAY_count(_files), sizeof(*_files), (int (*)(const void *, const void *))compare_path); 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) if (main_verbose)
puts("Removing .info and .list files"); puts("Removing .info and .list files");
chdir(FILE_get_dir(COMP_project)); FILE_chdir(FILE_get_dir(COMP_project));
unlink(".info"); unlink(".info");
unlink(".list"); unlink(".list");
} }

View File

@ -45,6 +45,8 @@
/*#define DEBUG*/ /*#define DEBUG*/
#define TEMP_EXEC ".temp.gambas"
char *ARCH_project; char *ARCH_project;
char *ARCH_project_name; char *ARCH_project_name;
char *ARCH_output = NULL; char *ARCH_output = NULL;
@ -101,22 +103,46 @@ static void write_string(const char *str, int len)
static void make_executable(void) static void make_executable(void)
{ {
const char *err;
struct stat info; struct stat info;
if (stat(ARCH_output, &info) == 0) FILE_chdir(FILE_get_dir(ARCH_project));
if (chmod(ARCH_output, info.st_mode | S_IXUSR | S_IXGRP | S_IXOTH) == 0)
{ if (stat(TEMP_EXEC, &info) || chmod(TEMP_EXEC, info.st_mode | S_IXUSR | S_IXGRP | S_IXOTH))
FILE_set_owner(ARCH_output, FILE_cat(FILE_get_dir(ARCH_project), ".project", NULL)); {
return; 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) void ARCH_define_output(const char *path)
{ {
STR_free(ARCH_output); STR_free(ARCH_output);
if (path && *path != '/')
path = FILE_cat(FILE_get_current_dir(), path, NULL);
ARCH_output = STR_copy(path); ARCH_output = STR_copy(path);
} }
@ -129,7 +155,7 @@ void ARCH_define_project(const char *project)
if (project == NULL) if (project == NULL)
project = FILE_get_current_dir(); project = FILE_get_current_dir();
chdir(project); FILE_chdir(project);
dir = STR_copy(FILE_get_current_dir()); dir = STR_copy(FILE_get_current_dir());
arch_dir_pos = strlen(dir) + 1; arch_dir_pos = strlen(dir) + 1;
@ -159,7 +185,7 @@ void ARCH_init(void)
ALLOC(&arch_buffer, 4096, "ARCH_init"); ALLOC(&arch_buffer, 4096, "ARCH_init");
arch_file = fopen(ARCH_output, "w"); arch_file = fopen(".temp.gambas", "w");
if (arch_file == NULL) if (arch_file == NULL)
THROW("Cannot create temporary archive file: &1", ARCH_output); THROW("Cannot create temporary archive file: &1", ARCH_output);

View File

@ -280,7 +280,7 @@ bool ARCHIVE_get(ARCHIVE *arch, const char **ppath, ARCHIVE_FIND *find)
if (get_current(&arch, ppath)) if (get_current(&arch, ppath))
{ {
// no archive found, we try a lstat // no archive found, we try a lstat
chdir(PROJECT_path); FILE_chdir(PROJECT_path);
if (stat(*ppath, &buf)) if (stat(*ppath, &buf))
return TRUE; return TRUE;

View File

@ -354,8 +354,10 @@ BEGIN_PROPERTY(System_Domain)
char buffer[256]; char buffer[256];
getdomainname(buffer, 255); if (getdomainname(buffer, 255))
GB_ReturnNewZeroString(buffer); GB_Error("Unable to retrieve domain name: &1", strerror(errno));
else
GB_ReturnNewZeroString(buffer);
END_PROPERTY END_PROPERTY

View File

@ -538,7 +538,7 @@ static void run_process(CPROCESS *process, int mode, void *cmd, CARRAY *env)
} }
// Return to the parent working directory // Return to the parent working directory
chdir(PROJECT_oldcwd); FILE_chdir(PROJECT_oldcwd);
if (env) if (env)
{ {
@ -569,7 +569,8 @@ static void callback_child(int fd, int type, void *data)
/*old = signal(SIGCHLD, signal_child);*/ /*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 #ifdef DEBUG_ME
fprintf(stderr, "<< callback_child\n"); fprintf(stderr, "<< callback_child\n");
@ -615,7 +616,8 @@ static void signal_child(int sig)
return; return;
buffer = 42; buffer = 42;
write(_pipe_child[1], &buffer, 1); if (write(_pipe_child[1], &buffer, 1) != 1)
ERROR_panic("Cannot write into SIGCHLD pipe");
} }

View File

@ -532,13 +532,16 @@ static void load_and_relocate(CLASS *class, int len_data, int *pndesc, int *pfir
{ {
int fd; 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) 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); 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", ""); THROW(E_CLASS, ClassName, "Bad header", "");
} }

View File

@ -346,7 +346,7 @@ void PROJECT_init(const char *file)
{ {
path = FILE_get_dir(file); path = FILE_get_dir(file);
chdir(path); FILE_chdir(path);
path = FILE_getcwd(NULL); path = FILE_getcwd(NULL);
if (path == NULL) if (path == NULL)
@ -389,7 +389,7 @@ void PROJECT_init(const char *file)
PROJECT_path = STRING_new(path, len); PROJECT_path = STRING_new(path, len);
chdir(PROJECT_path); FILE_chdir(PROJECT_path);
/* Project name */ /* Project name */

View File

@ -669,7 +669,7 @@ void SUBR_isdir(void)
path = get_path(PARAM); path = get_path(PARAM);
isdir = FILE_isdir(path); isdir = FILE_is_dir(path);
RETURN->type = T_BOOLEAN; RETURN->type = T_BOOLEAN;
RETURN->_integer.value = isdir ? -1 : 0; RETURN->_integer.value = isdir ? -1 : 0;

View File

@ -86,10 +86,10 @@ const char *FILE_set_ext(const char *path, const char *ext);
const char *FILE_getcwd(const char *subdir); const char *FILE_getcwd(const char *subdir);
#define FILE_get_current_dir() FILE_getcwd(NULL) #define FILE_get_current_dir() FILE_getcwd(NULL)
void FILE_chdir(const char *path);
const char *FILE_readlink(const char *link); const char *FILE_readlink(const char *link);
bool FILE_is_dir(const char *path); bool FILE_is_dir(const char *path);
#define FILE_isdir FILE_is_dir
const char *FILE_find_gambas(void); const char *FILE_find_gambas(void);

View File

@ -433,7 +433,7 @@ bool FILE_exist_real(const char *path)
{ {
struct stat buf; struct stat buf;
chdir(PROJECT_path); if (chdir(PROJECT_path)) return FALSE;
return (stat(path, &buf) == 0); return (stat(path, &buf) == 0);
} }
@ -941,3 +941,13 @@ const char *FILE_find_gambas(void)
return path; 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
}