Commit graph

3370 commits

Author SHA1 Message Date
Andreas Kling
10d120dc85 AK: Share code between NonnullOwnPtrVector and NonnullRefPtrVector.
These can just inherit from a shared base template. Thanks to Robin for the
sweet idea :^)
2019-07-25 11:00:26 +02:00
Andreas Kling
7c3b2e0728 Shell: Simply print "cmd: Command not found." for ENOENT on execution.
This looks a little nicer than 'execvp(cmd): No such file or directory'
2019-07-25 07:05:38 +02:00
Andreas Kling
f186c018f1 LibC: Fix execvpe() exiting with bad errno when giving up.
This is still not perfect, but at least it fixes one such issue.
2019-07-25 07:05:05 +02:00
Andreas Kling
0846986cac LogStream: Preserve errno for the lifetime of a LogStream object. 2019-07-25 07:00:33 +02:00
Andreas Kling
1d0b464618 AK: Make HashMap::get(Key) return an Optional<Value>.
This allows HashMap::get() to be used for value types that cannot be default
constructed (e.g NonnullOwnPtr.)
2019-07-24 10:25:43 +02:00
Andreas Kling
e2798d6208 VisualBuilder: Convert Vector<OwnPtr> to NonnullOwnPtrVector. 2019-07-24 09:40:11 +02:00
Andreas Kling
31a2a6ca2d Terminal: Convert Vector<OwnPtr> to NonnullOwnPtrVector. 2019-07-24 09:36:58 +02:00
Andreas Kling
1686c4906b AK: Delete Vector::resize() from Nonnull{Own,Ref}PtrVector.
It's not possible to grow one of these vectors beyond what's already in them
since it's not possible to default-construct Nonnull{Own,Ref}Ptr.

Add Vector::shrink() which can be used when you want to shrink the Vector
and delete resize() from the specialized Vectors.
2019-07-24 09:33:26 +02:00
Andreas Kling
394168c0ca Kernel: Convert Vector<OwnPtr> to NonnullOwnPtrVector. 2019-07-24 09:15:33 +02:00
Andreas Kling
2196f17c10 LibGUI: Convert Vector<OwnPtr> to NonnullOwnPtrVector.
This is turning out really nice so far. :^)
2019-07-24 09:13:06 +02:00
Andreas Kling
90ea4918d6 WindowServer: Convert Vector<OwnPtr> to NonnullOwnPtrVector. 2019-07-24 09:04:57 +02:00
Andreas Kling
a635e62e6a AK: Add NonnullOwnPtrVector.
This works just like NonnullRefPtr, except for NonnullOwnPtr's instead.
NonnullOwnPtrVector<T> inherits from Vector<NonnullOwnPtr<T>>, and adds some
comforts on top, like making accessors return T& so we can chase dots (.)
instead of arrows (->) :^)
2019-07-24 08:49:44 +02:00
Andreas Kling
93489fbc4c Convert HashMap<Key, OwnPtr<T>> to HashMap<Key, NonnullOwnPtr<T>>.
In every case I found, we never wanted to support null entry values.
With NonnullOwnPtr, we can encode that at the type level. :^)
2019-07-24 08:42:55 +02:00
Andreas Kling
3c5befde36 CEventLoop: Use NonnullOwnPtr for QueuedEvent::event.
We don't allow null events in the event queue. :^)
2019-07-24 08:38:28 +02:00
Andreas Kling
28da5b002f AK: Add NonnullOwnPtr.
This is just like OwnPtr (also single-owner), except it cannot be null.

NonnullOwnPtr is perfect as the return type of functions that never need to
return nullptr.

It's also useful as an argument type to encode the fact that the argument
must not be nullptr.

The make<Foo>() helper is changed to return NonnullOwnPtr<Foo>.

Note: You can move() out of a NonnullOwnPtr, and after that the object is
in an invalid state. Internally it will be a nullptr at this point, so we'll
still catch misuse, but the only thing that should be done in this state
is running the destructor. I've used consumable annotations to generate some
warnings when using a NonnullOwnPtr after moving from it, but these only
work when compiling with clang, so be aware of that.
2019-07-24 08:32:11 +02:00
Andreas Kling
ecc35876af AK: Move clang-specific consumable annotation helpers to Platform.h 2019-07-24 08:16:59 +02:00
Andreas Kling
f88c5860df LibHTML: Fetch the box edge values needed for block width computation. 2019-07-24 07:34:07 +02:00
Andreas Kling
af23b38418 LibHTML: Fix host build. 2019-07-24 07:27:07 +02:00
Andreas Kling
adb7b1bc4c AK: Add Optional::value_or(T).
This is like value() but with a fallback in case there's no value set.
2019-07-24 07:26:02 +02:00
Andreas Kling
442256b5f8 TextEditor: Add "Save as..." action.
Add a basic "save as" action to the TextEditor app, and make "save" fall
back to using "save as" if there's no name already set.

Fixes #282.
2019-07-24 06:32:30 +02:00
Andreas Kling
1f8f739ea2 Kernel: Simplify PhysicalPage construction.
There was some leftover cruft from the times when PhysicalPage was allocated
using different allocators depending on lifetime.
2019-07-24 06:29:47 +02:00
Andreas Kling
356babaf96 LibGUI: Destroy tooltip windows when they are not used.
Cached tooltip windows were preventing the automatic event loop shutdown.
It's not like we were gaining much by caching these anyway, since we only
cached the GWindow, not anything on the WindowServer side.
2019-07-23 20:51:08 +02:00
Andreas Kling
72a3f69df7 LibGUI: Get rid of GWindow::should_exit_event_loop_on_close().
This behavior and API was extremely counter-intuitive since our default
behavior was for applications to never exit after you close all of their
windows.

Now that we exit the event loop by default when the very last GWindow is
deleted, we don't have to worry about this.
2019-07-23 18:20:00 +02:00
Andreas Kling
fbae03b737 LibGUI: Exit the main event loop when the last window is deleted.
This behavior is the new opt-out default. If you don't want your app to exit
when the last GWindow is destroyed, call this:

    - void GApplication::set_quit_set_quit_when_last_window_deleted(bool)

Also renamed "windows()" to "reified_windows" in GWindow.cpp to reflect that
it only contains GWindows that have a server-side representation. :^)
2019-07-23 18:16:25 +02:00
Andreas Kling
528d8d49dc LibDraw: Add LogStream operator<< overload for Color. 2019-07-23 14:56:42 +02:00
Andreas Kling
66646081b7 CEventLoop: Avoid undefined evaluation order in register_timer(). 2019-07-23 14:55:12 +02:00
Andreas Kling
67fe583f6a Piano: Exit the event loop on main window close. 2019-07-23 06:45:00 +02:00
Andreas Kling
0d1ad84656 PaintBrush: Exit the event loop on main window close. 2019-07-23 06:44:47 +02:00
Andreas Kling
b312215d33 GDirectoryModel: Don't forget to drain the watch descriptor. 2019-07-22 20:12:35 +02:00
Andreas Kling
1511cac715 GDirectoryModel: Automagically update on filesystem changes.
Use the new watch_file() mechanism to monitor the currently open directory
for changes and refresh the model when notified. This makes FileManager
automagically show newly added files. :^)
2019-07-22 20:08:25 +02:00
Andreas Kling
c8e2bb5605 Kernel: Add a mechanism for listening for changes to an inode.
The syscall is quite simple:

    int watch_file(const char* path, int path_length);

It returns a file descriptor referring to a "InodeWatcher" object in the
kernel. It becomes readable whenever something changes about the inode.

Currently this is implemented by hooking the "metadata dirty bit" in
Inode which isn't perfect, but it's a start. :^)
2019-07-22 20:01:11 +02:00
Andreas Kling
a9adf4c95b DevPtsFS: Use String::number() in a place where it makes sense. 2019-07-22 10:42:34 +02:00
Robin Burchell
342f7a6b0f Move runnable/non-runnable list control entirely over to Scheduler
This way, we can change how the scheduler works without having to change Thread too.
2019-07-22 09:42:39 +02:00
Andreas Kling
c1ed16c8e8 Toolchain: Oops, we can't rely on "install.sh" to build LibC/LibM.
When we used "make install" in the past, the "install" target would pull
in the library targets as dependencies, and everything got built that way.
Now that we use "install.sh" instead, we have to build things manually.
2019-07-22 08:48:08 +02:00
Andreas Kling
acb7710a62 Toolchain: Use "install.sh" to install LibC and LibM. 2019-07-21 21:57:22 +02:00
Andreas Kling
facfaa50df AK: Remove unused Vector::shift_left().
I was using this for a makeshift queue, but now there is AK::Queue.
2019-07-21 21:46:03 +02:00
Andreas Kling
af81645a2a Kernel+LibC: Add a dbgputstr() syscall for sending strings to debug output.
This is very handy for the DebugLogStream implementation, among others. :^)
2019-07-21 21:43:37 +02:00
Andreas Kling
0ef13e60b0 Libraries: Fix wrong paths to "Root" in the various install.sh scripts.
We were installing libraries into /Libraries/Root, rather than in /Root.
This made the ports system behave rather unpredictable, since I had old
versions of things in /Root and new versions of things in /Libraries/Root.
2019-07-21 21:38:30 +02:00
Andreas Kling
c7ea94697e Libraries: Remove unused "install" targets.
We've been using a per-directory "install.sh" for some time, so let's get
rid of the old way of doing things.
2019-07-21 21:28:48 +02:00
Andreas Kling
38b13f1508 Kernel: Remove bitrotted "spawn stress" code.
This was something I used during early kernel development to spam creation
of new processes to see if the kernel could handle it.
2019-07-21 19:51:32 +02:00
Andreas Kling
3fce2fb205 Kernel+LibC: Add a dbgputch() syscall and use it for userspace dbgprintf().
The "stddbg" stream was a cute idea but we never ended up using it in
practice, so let's simplify this and implement userspace dbgprintf() on top
of a simple dbgputch() syscall instead.

This makes debugging LibC startup a little bit easier. :^)
2019-07-21 19:45:31 +02:00
Andreas Kling
be7dcca1a6 Ports: Add GNU make 4.2! :^) 2019-07-21 19:26:02 +02:00
Robin Burchell
a3213659dd AK: Run host tests on make
Restructure the makefile a little so it only builds objects once, and
then run them on make clean.

This is a little slower (since we're relinking tests each makeall), but
it also ensures that it will work.
2019-07-21 18:48:44 +02:00
Andreas Kling
3b588b7dc0 Ext2FS: Put most debug logging behind EXT2_DEBUG.
The debug output was basically dominated by Ext2FS spam.
2019-07-21 18:38:14 +02:00
Robin Burchell
f2c0e55070 Userspace: Deal with select() returning EINTR on a signal interruption
Add a trivial CSafeSyscall template that calls a callback until it stops
returning EINTR, and use it everywhere we use select() now.

Thanks to Andreas for the suggestion of using a template parameter for
the syscall function to invoke.
2019-07-21 14:27:14 +02:00
Robin Burchell
a1eff3daba Process: Fix select/poll EINTR
Check for EINTR before doing anything with the passed sets, otherwise we
zero them out which means a re-call with the same sets won't work.
2019-07-21 14:27:14 +02:00
Andreas Kling
29a62558c4 AK: Fix off-by-one in Vector::prepend(Vector&&).
Caught by valgrind's uninitialized access checks on the Vector unit test.
Yay for finding bugs with valgrind on the unit tests! :^)
2019-07-21 12:55:39 +02:00
Andreas Kling
20c6edc976 AK: Make NonnullRefPtr::operator=(NonnullRefPtr<U>&&) cast incoming pointer.
Same as the RefPtr issue I just fixed. This makes it possible to assign a
NonnullRefPtr<Derived>&& to a NonnullRefPtr<Base>.
2019-07-21 12:55:39 +02:00
Robin Burchell
dea7f937bf Scheduler: Allow reentry into block()
With the presence of signal handlers, it is possible that a thread might
be blocked multiple times. Picture for instance a signal handler using
read(), or wait() while the thread is already blocked elsewhere before
the handler is invoked.

To fix this, we turn m_blocker into a chain of handlers. Each block()
call now prepends to the list, and unblocking will only consider the
most recent (first) blocker in the chain.

Fixes #309
2019-07-21 12:42:22 +02:00
Robin Burchell
a9db382f0e TestSuite: Don't leak the suite instance
Makes checking for leaks more straightforward
2019-07-21 11:51:10 +02:00