general: bugfixes

This commit is contained in:
nakst 2022-03-25 11:17:57 +00:00
parent a20b6fe91f
commit 4276411dba
6 changed files with 23 additions and 9 deletions

View File

@ -2,6 +2,9 @@
// It is released under the terms of the MIT license -- see LICENSE.md.
// Written by: nakst.
// TODO Terminating the child process on exit.
// TODO Handle ES_MSG_INSTANCE_CLOSE, and ignore following MSG_RECEIVED_OUTPUTs.
#include <essence.h>
#include <shared/strings.cpp>

View File

@ -753,6 +753,7 @@ EsInstance *_EsInstanceCreate(size_t bytes, EsMessage *message, const char *appl
// TODO Can the posted message be raced by a ES_MSG_INSTANCE_DOCUMENT_UPDATED?
EsMessage m = { ES_MSG_INSTANCE_OPEN_DELAYED };
m._argument = instance;
EsInstanceOpenReference(instance);
EsMessagePost(nullptr, &m);
}
}
@ -1131,11 +1132,15 @@ EsMessage *EsMessageReceive() {
EsHandleClose(message.message.tabOperation.handle);
}
} else if (type == ES_MSG_INSTANCE_OPEN_DELAYED) {
InstanceSendOpenMessage((EsInstance *) message.message._argument, false);
EsInstance *instance = (EsInstance *) message.message._argument;
InstanceSendOpenMessage(instance, false);
EsInstanceCloseReference(instance);
} else if (type == ES_MSG_INSTANCE_SAVE_COMPLETE_DELAYED) {
char buffer[1];
buffer[0] = DESKTOP_MSG_COMPLETE_SAVE;
MessageDesktop(buffer, 1, ((EsInstance *) message.message._argument)->window->handle);
EsInstance *instance = (EsInstance *) message.message._argument;
MessageDesktop(buffer, 1, instance->window->handle);
EsInstanceCloseReference(instance);
} else if (type == ES_MSG_PRIMARY_CLIPBOARD_UPDATED) {
EsInstance *instance = InstanceFromWindowID(message.message.tabOperation.id);
if (instance) UIRefreshPrimaryClipboard(instance->window);
@ -1243,6 +1248,7 @@ void EsInstanceSaveComplete(EsInstance *instance, EsFileStore *file, bool succes
if (instance) {
// HACK Post this message so that our handle to the file is (hopefully) closed first.
EsMessage m = { .type = ES_MSG_INSTANCE_SAVE_COMPLETE_DELAYED, ._argument = instance };
EsInstanceOpenReference(instance);
EsMessagePost(nullptr, &m);
if (success) {

View File

@ -787,9 +787,12 @@ int ProcessWindowBorderMessage(EsWindow *window, EsMessage *message, EsRectangle
// --------------------------------- Windows.
void UIWindowNeedsUpdate(EsWindow *window) {
if (!window->willUpdate) {
if (!window->willUpdate && window->handle /* cleared in UIWindowDestroy, during InternalDestroy */) {
EsMessage m = { ES_MSG_UPDATE_WINDOW };
// Don't use the userland posted message queue, since we don't want this to block WM messages.
// This message will be received within the window's lifetime,
// because the window cannot be deallocated until ES_MSG_WINDOW_DESTROYED is received,
// and this message will always be received first.
EsSyscall(ES_SYSCALL_MESSAGE_POST, (uintptr_t) &m, (uintptr_t) window, ES_CURRENT_PROCESS, 0);
window->willUpdate = true;
}

View File

@ -65,6 +65,7 @@ bool runningTests;
#define PATH_MAX 1024
#endif
#define DEPENDENCIES_FILE "bin/dependency_files/dependencies_utils.ini"
#include "build_common.h"
BuildFont fonts[] = {
@ -255,7 +256,6 @@ void DoCommand(const char *l);
#define OPTIMISE_FULL (1 << 6)
void Compile(uint32_t flags, int partitionSize, const char *volumeLabel) {
buildStartTimeStamp = time(NULL);
BuildUtilities();
if (!BuildAPIDependencies()) {
@ -384,8 +384,6 @@ void Compile(uint32_t flags, int partitionSize, const char *volumeLabel) {
void BuildUtilities() {
#define WARNING_FLAGS " -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-function -Wno-format-truncation -Wno-unused-parameter "
buildStartTimeStamp = time(NULL);
#define BUILD_UTILITY(x, y, z) \
if (CheckDependencies("Utilities." x)) { \
if (!CallSystem("gcc -MMD -MF \"bin/dependency_files/" x ".d\" " "util/" z x ".c -o bin/" x " -g " WARNING_FLAGS " " y)) { \
@ -987,6 +985,7 @@ void BuildAndRun(int optimise, bool compile, int debug, int emulator, int log) {
}
if (!runningTests) {
DependenciesListWrite();
exit(encounteredErrors ? 1 : 0);
}
}
@ -1424,6 +1423,7 @@ int main(int _argc, char **_argv) {
coloredOutput = isatty(STDERR_FILENO);
systemLog = fopen("bin/Logs/system.log", "a");
if (!systemLog) systemLog = fopen("bin/Logs/system.log", "w");
buildStartTimeStamp = time(NULL);
if (argc < 2) {
fprintf(stderr, "Error: No command specified.\n");
@ -1439,6 +1439,8 @@ int main(int _argc, char **_argv) {
strcat(buffer, argv[i]);
}
DependenciesListRead();
DoCommand(buffer);
DependenciesListWrite();
return 0;
}

View File

@ -107,7 +107,6 @@ bool CheckDependencies(const char *applicationName) {
struct stat s = { 0 };
if (stat(dependencies.files[i], &s) || s.st_mtime > dependencies.timeStamp) {
// printf("%s, %s, %ld, %ld\n", applicationName, dependencies.files[i], s.st_mtime, dependencies.timeStamp);
needsRebuild = true;
break;
}
@ -182,7 +181,7 @@ void ParseDependencies(const char *dependencyFile, const char *applicationName,
}
void DependenciesListRead() {
EsINIState s = { .buffer = (char *) LoadFile("bin/dependencies.ini", &s.bytes) };
EsINIState s = { .buffer = (char *) LoadFile(DEPENDENCIES_FILE, &s.bytes) };
char *start = s.buffer;
if (!start) return;
@ -229,7 +228,7 @@ void DependenciesListWrite() {
#ifdef OS_ESSENCE
// TODO.
#else
FILE *f = fopen("bin/dependencies.ini", "wb");
FILE *f = fopen(DEPENDENCIES_FILE, "wb");
fprintf(f, "[general]\nconfiguration_hash=%lu\n", configurationHash);

View File

@ -157,6 +157,7 @@ File FileOpen(const char *path, char mode) {
#include "../shared/crc.h"
#include "../shared/partitions.cpp"
#define DEPENDENCIES_FILE "bin/dependency_files/dependencies.ini"
#include "build_common.h"
#include "../shared/esfs2.h"
#include "header_generator.c"