Commit graph

4346 commits

Author SHA1 Message Date
Andreas Kling
87e768f0e3 Userland: Unbreak "copy" and "paste" after GEventLoop removal
Have these programs instantiate a GApplication to ensure they get a
connection to the WindowServer, otherwise the clipboard will not work.

Sorry Sergey! :^)
2019-09-23 09:36:25 +02:00
Andreas Kling
a1907011b2 CSocket: Don't create the read notifier until after we've connected
This makes it so that "on_connected" always gets called first.
Since accepted sockets are connected before construction, they have
to manually set CSocket::m_connected.
2019-09-22 21:46:46 +02:00
Andreas Kling
65409e8f04 LocalSocket: Teach recvfrom() how to block if needed, and simplify it
If we can't already read when we enter recvfrom() on a LocalSocket,
we'll now block the current thread until we can.

Also added a buffer_for(FileDescription&) helper so that the client
and server can share some of the code. :^)
2019-09-22 21:30:30 +02:00
Andreas Kling
34d0e96aec LibCore+LibGUI: Remove GEventLoop and use CEventLoop everywhere
GEventLoop was just a dummy subclass of CEventLoop anyway. The only
thing it actually did was make sure a GWindowServerConnectionw was
instantiated. We now take care of that in GApplication instead.

CEventLoop is now non-virtual and a little less confusing. :^)
2019-09-22 20:50:39 +02:00
Andreas Kling
edac8704de LibC: Fix dumb off-by-two in fgets() :^)
"Play C games, win C prizes."
2019-09-22 20:03:02 +02:00
Andreas Kling
64948fa701 LibC: ungetc(EOF) should fail (and return EOF) 2019-09-22 19:51:39 +02:00
Andreas Kling
bba24b09f7 Kernel: Avoid creating a temporary String("mmap") for every mmap() call 2019-09-22 19:47:00 +02:00
Andreas Kling
804df54296 LibC: Let's assert in rewind() that fseek()ing to the beginning worked 2019-09-22 19:41:21 +02:00
Andreas Kling
e364846622 Ext2FS: Don't allocate blocks until we're committed to a new inode
Otherwise we would leak the blocks in case we returned earlier than
expected. :^)
2019-09-22 18:50:24 +02:00
Andreas Kling
bd7c38e7b6 Ext2FS: Oops, fix wrong ENOSPC in create_inode() 2019-09-22 18:44:05 +02:00
Andreas Kling
bff59eff4b Ext2FS: Fix two bugs in block allocation:
1) Off-by-one in block allocation when block size != 1 KB

Due to a quirk in the on-disk layout of ext2, file systems with a block
size of 1 KB have block #1 as their first block, while all others start
on block #0.

2) We had no fallback mechanism when the preferred group was full

We now allocate blocks from the preferred block group as long as it's
possible, and fall back to a simple scan through all groups when the
preferred one is full.
2019-09-22 18:37:17 +02:00
Andreas Kling
9c549c178a Kernel: Pad virtual address space allocations with guard pages
Put one unused page on each side of VM allocations to make invalid
accesses more likely to generate crashes.

Note that we will not add this guard padding for mmap() at a specific
memory address, only to "mmap it anywhere" requests.
2019-09-22 15:12:29 +02:00
Andreas Kling
bd1e8bf166 GDialog: Remove self from parent when the nested event loop returns
This ensures that we close (and don't leak) the dialog during the
typical usage pattern.
2019-09-22 00:46:29 +02:00
Andreas Kling
e61aa01745 WindowServer: Remove debug spam about child window removals 2019-09-22 00:44:18 +02:00
Andreas Kling
5614cdf308 LibCore: Remove leftover debug spam in CObject::remove_child() 2019-09-22 00:42:20 +02:00
Andreas Kling
df837562ad Taskbar: Remove window buttons from the taskbar when appropriate 2019-09-22 00:41:52 +02:00
Andreas Kling
f614081b83 LibCore: Add CObject::remove_from_parent()
This is a convenient shorthand for:

    if (object.parent())
        object.parent()->remove_child(object);
2019-09-22 00:41:01 +02:00
Andreas Kling
d6abfbdc5a LibCore: Remove ObjectPtr in favor of RefPtr
Now that CObject is fully ref-counted, just use RefPtr everywhere! :^)
2019-09-22 00:31:54 +02:00
Andreas Kling
bc319d9e88 LibCore: Make CObject reference-counted
Okay, I've spent a whole day on this now, and it finally kinda works!
With this patch, CObject and all of its derived classes are reference
counted instead of tree-owned.

The previous, Qt-like model was nice and familiar, but ultimately also
outdated and difficult to reason about.

CObject-derived types should now be stored in RefPtr/NonnullRefPtr and
each class can be constructed using the forwarding construct() helper:

    auto widget = GWidget::construct(parent_widget);

Note that construct() simply forwards all arguments to an existing
constructor. It is inserted into each class by the C_OBJECT macro,
see CObject.h to understand how that works.

CObject::delete_later() disappears in this patch, as there is no longer
a single logical owner of a CObject.
2019-09-22 00:25:25 +02:00
Andreas Kling
0c72e0c09f AK: Add AK_MAKE_NONMOVABLE 2019-09-22 00:17:29 +02:00
Andreas Kling
8d550c174e LibCore: Convert CFile to ObjectPtr 2019-09-21 20:50:06 +02:00
Andreas Kling
31b38ed88f LibGUI: Don't create GMessageBox and GInputBox on the stack
We need to get rid of all instances of widgets-on-the-stack since that
will no longer work in the ref-counting world.
2019-09-21 20:32:31 +02:00
Andreas Kling
defafd72bc LibGUI: Convert custom widgets and subclasses to ObjectPtr 2019-09-21 20:04:00 +02:00
Andreas Kling
15a66dc8ab Welcome: Unbreak after ObjectPtr changes 2019-09-21 19:42:16 +02:00
Andreas Kling
409494193e LibGUI: Convert remaining random little things to ObjectPtr 2019-09-21 19:40:14 +02:00
Andreas Kling
81a5c4fc56 GButton: Make the constructors protected in favor of construct() 2019-09-21 19:37:38 +02:00
Andreas Kling
60530a7cd9 Calculator: Convert to using ObjectPtr 2019-09-21 19:37:28 +02:00
Andreas Kling
45cfd57f6e GButton: Convert most code to using ObjectPtr for GButton 2019-09-21 19:28:28 +02:00
Andreas Kling
55a6e4ac0b LibGUI: Convert GFrame to ObjectPtr 2019-09-21 19:21:36 +02:00
Andreas Kling
7b5342b2e3 LibGUI: Convert GCheckBox to ObjectPtr 2019-09-21 18:58:48 +02:00
Andreas Kling
f8d751440b LibGUI: Convert GRadioButton to ObjectPtr 2019-09-21 18:58:03 +02:00
Andreas Kling
870bc2a4d1 LibGUI: Get rid of GWindow's destroy-on-close mechanism
Since we're moving to a world of ref-counting, we can't have weird
behaviors like "windows delete themselves when you close them."

The "close app when there are no more windows" mechanism is moved
to GWindow::hide(). Now, we close the app when it has no more
windows on screen.
2019-09-21 18:53:17 +02:00
Andreas Kling
7584480f62 LibGUI: Convert GWindow to ObjectPtr 2019-09-21 18:34:06 +02:00
Andreas Kling
70412c7d4f DisplayProperties: Remove all remaining naked "new" usage 2019-09-21 18:18:47 +02:00
Andreas Kling
f57cc5873c SystemMonitor: Remove all remaining naked "new" usage 2019-09-21 18:17:23 +02:00
Andreas Kling
f4b51a63ec LibCore: Remove CTimer::create() overloads in favor of construct() 2019-09-21 18:13:17 +02:00
Andreas Kling
9e00651e14 LibCore: ObjectPtr should delete the pointee when cleared
We were only deleting the pointee when the ObjectPtr was destroyed.
If the ObjectPtr is cleared before that, we should also delete the
pointee. This is not the most important class to get right, since
it will go away as soon as we're able to switch to RefPtr.
2019-09-21 18:07:46 +02:00
Andreas Kling
4d8455156e CHttpJob: Shutting down the job should actually destroy the socket
It's pretty confusing when a CObject is owned both by its parent-child
relationship, but also by an ObjectPtr member in the parent.
In those cases, we have to make sure we both unparent the child *and*
reove it from the ObjectPtr.

This will become a bit less confusing when ObjectPtr becomes RefPtr,
although still not crystal clear. I'm not sure what the solution is.
2019-09-21 18:05:34 +02:00
Andreas Kling
0c4508c00d SystemMonitor: Unbreak after ObjectPtr<GWidget> changes 2019-09-21 17:36:52 +02:00
Andreas Kling
bdf23a3d23 LibCore: Make it possible to cancel pending CNetworkJobs
Subclasses of CNetworkJob handle this by overriding shutdown().
This patch implements it for CHttpJob by simply tearing down the
underlying socket.

We also automatically call shutdown() after the job finishes,
regardless of success or failure. :^)
2019-09-21 17:32:26 +02:00
Andreas Kling
ff6ce422dd LibGUI: Convert GWidget to ObjectPtr 2019-09-21 17:05:35 +02:00
Andreas Kling
e4e92980a1 LibGUI: Convert GComboBox to ObjectPtr 2019-09-21 16:35:11 +02:00
Andreas Kling
7aaad27778 LibGUI: Convert GSlider to ObjectPtr 2019-09-21 16:33:53 +02:00
Andreas Kling
a50cfc5f1f Boot: Bump our requested resolution to 1280x1024
This makes bare metal boots a bit nicer on machines where that mode
is available to us.
2019-09-21 16:31:52 +02:00
Andreas Kling
ceb5508fea LibGUI: Convert GProgressBar to ObjectPtr 2019-09-21 16:31:12 +02:00
Andreas Kling
3476a63415 LibGUI: Convert GStatusBar to ObjectPtr 2019-09-21 16:29:47 +02:00
Andreas Kling
f4531c976c LibGUI: Convert GToolBar to ObjectPtr 2019-09-21 16:27:54 +02:00
Andreas Kling
b78225941d LibGUI: Convert GSpinBox to ObjectPtr 2019-09-21 16:15:11 +02:00
Andreas Kling
83b5f6c11a LibGUI: Convert GGroupBox to ObjectPtr 2019-09-21 16:13:33 +02:00
Andreas Kling
4f4438c04c LibGUI: Convert GSplitter to ObjectPtr 2019-09-21 16:11:02 +02:00